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:
Kier Davis 2016-07-11 14:53:37 +01:00
commit 56015e52b9

View file

@ -1746,8 +1746,8 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
if formal.ast == nil: if formal.ast == nil:
if formal.typ.kind == tyVarargs: if formal.typ.kind == tyVarargs:
var container = newNodeIT(nkBracket, n.info, arrayConstr(c, n.info)) var container = newNodeIT(nkBracket, n.info, arrayConstr(c, n.info))
addSon(m.call, implicitConv(nkHiddenStdConv, formal.typ, setSon(m.call, formal.position + 1,
container, m, c)) implicitConv(nkHiddenStdConv, formal.typ, container, m, c))
else: else:
# no default value # no default value
m.state = csNoMatch m.state = csNoMatch