summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2018-08-23 21:43:10 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-08-24 09:40:17 +0200
commitb1c2416abde695dc45ee6b2d97f4d8e125b68140 (patch)
tree01020a8e360a8d7c6a23bfb5a335993320d25e37 /compiler
parent30621c4a8969ac4b121d04a06315bd4f2089a7c4 (diff)
downloadNim-b1c2416abde695dc45ee6b2d97f4d8e125b68140.tar.gz
Validate pragmas attached to for variables (#8749)
Fixes #8741
Diffstat (limited to 'compiler')
-rw-r--r--compiler/pragmas.nim1
-rw-r--r--compiler/semstmts.nim2
2 files changed, 3 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