mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
fixes #4328
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user