fixes a varargs[untyped] bug that kept strscans from compiling
This commit is contained in:
parent
b357e80833
commit
875132bf46
1 changed files with 29 additions and 20 deletions
|
|
@ -1659,30 +1659,39 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
|
||||||
when false: localError(n.sons[a].info, errCannotBindXTwice, formal.name.s)
|
when false: localError(n.sons[a].info, errCannotBindXTwice, formal.name.s)
|
||||||
m.state = csNoMatch
|
m.state = csNoMatch
|
||||||
return
|
return
|
||||||
m.baseTypeMatch = false
|
|
||||||
n.sons[a] = prepareOperand(c, formal.typ, n.sons[a])
|
if formal.typ.isVarargsUntyped:
|
||||||
var arg = paramTypesMatch(m, formal.typ, n.sons[a].typ,
|
|
||||||
n.sons[a], nOrig.sons[a])
|
|
||||||
if arg == nil:
|
|
||||||
m.state = csNoMatch
|
|
||||||
return
|
|
||||||
if m.baseTypeMatch:
|
|
||||||
#assert(container == nil)
|
|
||||||
if container.isNil:
|
if container.isNil:
|
||||||
container = newNodeIT(nkBracket, n.sons[a].info, arrayConstr(c, arg))
|
container = newNodeIT(nkBracket, n.sons[a].info, arrayConstr(c, n.info))
|
||||||
|
setSon(m.call, formal.position + 1, container)
|
||||||
else:
|
else:
|
||||||
incrIndexType(container.typ)
|
incrIndexType(container.typ)
|
||||||
addSon(container, arg)
|
addSon(container, n.sons[a])
|
||||||
setSon(m.call, formal.position + 1,
|
|
||||||
implicitConv(nkHiddenStdConv, formal.typ, container, m, c))
|
|
||||||
#if f != formalLen - 1: container = nil
|
|
||||||
|
|
||||||
# pick the formal from the end, so that 'x, y, varargs, z' works:
|
|
||||||
f = max(f, formalLen - n.len + a + 1)
|
|
||||||
else:
|
else:
|
||||||
setSon(m.call, formal.position + 1, arg)
|
m.baseTypeMatch = false
|
||||||
inc(f)
|
n.sons[a] = prepareOperand(c, formal.typ, n.sons[a])
|
||||||
container = nil
|
var arg = paramTypesMatch(m, formal.typ, n.sons[a].typ,
|
||||||
|
n.sons[a], nOrig.sons[a])
|
||||||
|
if arg == nil:
|
||||||
|
m.state = csNoMatch
|
||||||
|
return
|
||||||
|
if m.baseTypeMatch:
|
||||||
|
#assert(container == nil)
|
||||||
|
if container.isNil:
|
||||||
|
container = newNodeIT(nkBracket, n.sons[a].info, arrayConstr(c, arg))
|
||||||
|
else:
|
||||||
|
incrIndexType(container.typ)
|
||||||
|
addSon(container, arg)
|
||||||
|
setSon(m.call, formal.position + 1,
|
||||||
|
implicitConv(nkHiddenStdConv, formal.typ, container, m, c))
|
||||||
|
#if f != formalLen - 1: container = nil
|
||||||
|
|
||||||
|
# pick the formal from the end, so that 'x, y, varargs, z' works:
|
||||||
|
f = max(f, formalLen - n.len + a + 1)
|
||||||
|
else:
|
||||||
|
setSon(m.call, formal.position + 1, arg)
|
||||||
|
inc(f)
|
||||||
|
container = nil
|
||||||
checkConstraint(n.sons[a])
|
checkConstraint(n.sons[a])
|
||||||
inc(a)
|
inc(a)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue