diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-06-03 23:06:59 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-06-03 23:07:07 +0200 |
commit | 1d44fee399868ebc6c5e412ee23c7fd1e4c37351 (patch) | |
tree | b48385d634fd8bfb1035eed73bde89fffa7e1ff0 | |
parent | 4e72e71284bbdcf18382eba027368acf365ca82f (diff) | |
download | Nim-1d44fee399868ebc6c5e412ee23c7fd1e4c37351.tar.gz |
hotfix: don't crash for wrong template calls
-rw-r--r-- | compiler/evaltempl.nim | 2 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim index e136265da..96ede44fd 100644 --- a/compiler/evaltempl.nim +++ b/compiler/evaltempl.nim @@ -79,7 +79,7 @@ proc evalTemplateArgs(n: PNode, s: PSym; fromHlo: bool): PNode = else: s.ast[genericParamsPos].len expectedRegularParams = <s.typ.len givenRegularParams = totalParams - genericParams - + if givenRegularParams < 0: givenRegularParams = 0 if totalParams > expectedRegularParams + genericParams: globalError(n.info, errWrongNumberOfArguments) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index e72db45e7..df27e3c1d 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -256,6 +256,7 @@ proc describeArgs*(c: PContext, n: PNode, startIdx = 1; add(result, renderTree(n.sons[i].sons[0])) add(result, ": ") 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]) n.sons[i].typ = arg.typ n.sons[i].sons[1] = arg |