diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2022-06-09 14:21:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 14:21:18 +0200 |
commit | 25d89269eb7fe7ebed142f2d3136959db11c9f02 (patch) | |
tree | d7e4b5c09f40b8696af776e87063223fc39a8d26 /compiler | |
parent | 836b95c896087a3f24bedad9bc1bcb2c5db1c5a8 (diff) | |
download | Nim-25d89269eb7fe7ebed142f2d3136959db11c9f02.tar.gz |
give a better error message for some template expansions (#19871)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semstmts.nim | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 3513fd767..0516d08ce 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -140,7 +140,9 @@ proc discardCheck(c: PContext, result: PNode, flags: TExprFlags) = n[0] = result elif result.typ.kind != tyError and c.config.cmd != cmdInteractive: var n = result - while n.kind in skipForDiscardable: n = n.lastSon + while n.kind in skipForDiscardable: + if n.kind == nkTryStmt: n = n[0] + else: n = n.lastSon var s = "expression '" & $n & "' is of type '" & result.typ.typeToString & "' and has to be used (or discarded)" if result.info.line != n.info.line or @@ -483,7 +485,7 @@ proc semVarMacroPragma(c: PContext, a: PNode, n: PNode): PNode = for i in 0 ..< pragmas.len: let it = pragmas[i] let key = if it.kind in nkPragmaCallKinds and it.len >= 1: it[0] else: it - + when false: let lhs = b[0] let clash = strTableGet(c.currentScope.symbols, lhs.ident) |