diff options
-rw-r--r-- | compiler/pragmas.nim | 1 | ||||
-rw-r--r-- | compiler/semstmts.nim | 2 | ||||
-rw-r--r-- | tests/pragmas/t8741.nim | 10 |
3 files changed, 13 insertions, 0 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 263068344..66682650d 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -71,6 +71,7 @@ const letPragmas* = varPragmas procTypePragmas* = {FirstCallConv..LastCallConv, wVarargs, wNosideeffect, wThread, wRaises, wLocks, wTags, wGcSafe} + forVarPragmas* = {wInject, wGensym} allRoutinePragmas* = methodPragmas + iteratorPragmas + lambdaPragmas proc getPragmaVal*(procAst: PNode; name: TSpecialWord): PNode = diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 6cf2e2d96..425bb24dc 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -567,6 +567,8 @@ proc symForVar(c: PContext, n: PNode): PSym = let m = if n.kind == nkPragmaExpr: n.sons[0] else: n result = newSymG(skForVar, m, c) styleCheckDef(c.config, result) + if n.kind == nkPragmaExpr: + pragma(c, result, n.sons[1], forVarPragmas) proc semForVars(c: PContext, n: PNode): PNode = result = n diff --git a/tests/pragmas/t8741.nim b/tests/pragmas/t8741.nim new file mode 100644 index 000000000..7398b1030 --- /dev/null +++ b/tests/pragmas/t8741.nim @@ -0,0 +1,10 @@ +discard """ + line: 9 + errormsg: "attempting to call undeclared routine: 'foobar'" +""" + +for a {.gensym, inject.} in @[1,2,3]: + discard + +for a {.foobar.} in @[1,2,3]: + discard |