mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-02 09:58:01 +00:00
Fix #4475
Existing implementation would append the default value for a varargs parameter (the empty array) to the end of the sons of the nnkCall node, rather than storing it into the correct index. This left the location where it should have been stored set to its default value of nil, causing later code that uses this node to segfault.
This commit is contained in:
@@ -1746,8 +1746,8 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
|
||||
if formal.ast == nil:
|
||||
if formal.typ.kind == tyVarargs:
|
||||
var container = newNodeIT(nkBracket, n.info, arrayConstr(c, n.info))
|
||||
addSon(m.call, implicitConv(nkHiddenStdConv, formal.typ,
|
||||
container, m, c))
|
||||
setSon(m.call, formal.position + 1,
|
||||
implicitConv(nkHiddenStdConv, formal.typ, container, m, c))
|
||||
else:
|
||||
# no default value
|
||||
m.state = csNoMatch
|
||||
|
||||
Reference in New Issue
Block a user