hotfix: don't crash for wrong template calls

This commit is contained in:
Andreas Rumpf 2016-06-03 23:06:59 +02:00
commit 1d44fee399
2 changed files with 2 additions and 1 deletions

View file

@ -79,7 +79,7 @@ proc evalTemplateArgs(n: PNode, s: PSym; fromHlo: bool): PNode =
else: s.ast[genericParamsPos].len else: s.ast[genericParamsPos].len
expectedRegularParams = <s.typ.len expectedRegularParams = <s.typ.len
givenRegularParams = totalParams - genericParams givenRegularParams = totalParams - genericParams
if givenRegularParams < 0: givenRegularParams = 0
if totalParams > expectedRegularParams + genericParams: if totalParams > expectedRegularParams + genericParams:
globalError(n.info, errWrongNumberOfArguments) globalError(n.info, errWrongNumberOfArguments)

View file

@ -256,6 +256,7 @@ proc describeArgs*(c: PContext, n: PNode, startIdx = 1;
add(result, renderTree(n.sons[i].sons[0])) add(result, renderTree(n.sons[i].sons[0]))
add(result, ": ") add(result, ": ")
if arg.typ.isNil and arg.kind notin {nkStmtList, nkDo}: if arg.typ.isNil and arg.kind notin {nkStmtList, nkDo}:
# XXX we really need to 'tryExpr' here!
arg = c.semOperand(c, n.sons[i].sons[1]) arg = c.semOperand(c, n.sons[i].sons[1])
n.sons[i].typ = arg.typ n.sons[i].typ = arg.typ
n.sons[i].sons[1] = arg n.sons[i].sons[1] = arg