fixes #4328
This commit is contained in:
parent
d455d58af6
commit
dc4b2c920c
2 changed files with 15 additions and 1 deletions
|
|
@ -1777,7 +1777,10 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
|
|||
break
|
||||
else:
|
||||
# use default value:
|
||||
setSon(m.call, formal.position + 1, copyTree(formal.ast))
|
||||
var def = copyTree(formal.ast)
|
||||
if def.kind == nkNilLit:
|
||||
def = implicitConv(nkHiddenStdConv, formal.typ, def, m, c)
|
||||
setSon(m.call, formal.position + 1, def)
|
||||
inc(f)
|
||||
|
||||
proc argtypeMatches*(c: PContext, f, a: PType): bool =
|
||||
|
|
|
|||
11
tests/typerel/tclosure_nil_as_default.nim
Normal file
11
tests/typerel/tclosure_nil_as_default.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
# bug #4328
|
||||
type
|
||||
foo[T] = object
|
||||
z: T
|
||||
|
||||
proc test[T](x: foo[T], p: proc(a: T) = nil) =
|
||||
discard
|
||||
|
||||
var d: foo[int]
|
||||
d.test() # <- param omitted
|
||||
Loading…
Add table
Add a link
Reference in a new issue