summary refs log tree commit diff stats
path: root/compiler/pragmas.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-11-26 22:15:33 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-11-27 00:36:29 +0100
commit93cf0ef52ef81af15009566f90e0d020903e8c2b (patch)
tree872220fcf81859bc4ff1044449de1ad4aea48138 /compiler/pragmas.nim
parent518c72e57a9c787a2d59b0895263427b4774ecad (diff)
downloadNim-93cf0ef52ef81af15009566f90e0d020903e8c2b.tar.gz
don't crash where there is an unknown statement pragma [backport]
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r--compiler/pragmas.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index ef5223559..62f70a090 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -1110,10 +1110,13 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
         else: sym.flags.incl sfUsed
       of wLiftLocals: discard
       else: invalidPragma(c, it)
-    elif sym.kind in {skVar,skLet,skParam,skField,skProc,skFunc,skConverter,skMethod,skType}:
+    elif sym != nil and sym.kind in {skVar, skLet, skParam, skField, skProc,
+                                     skFunc, skConverter, skMethod, skType}:
       n.sons[i] = semCustomPragma(c, it)
-    else:
+    elif sym != nil:
       illegalCustomPragma(c, it, sym)
+    else:
+      invalidPragma(c, it)
 
 proc implicitPragmas*(c: PContext, sym: PSym, n: PNode,
                       validPragmas: TSpecialWords) =