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
parent 9620e66533
commit 56015e52b9

View File

@@ -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