summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authordeech <aditya.siram@gmail.com>2018-12-31 07:41:24 -0600
committerAndreas Rumpf <rumpf_a@web.de>2018-12-31 14:41:24 +0100
commite87910197a209d02cf69bba3aacd9766723aeb37 (patch)
tree52ba4fa4156ea99420954370ff72ebb3910b4df3 /compiler/semstmts.nim
parentbcbe317d177e9a22856e8dd6c0ad1e20436b913a (diff)
downloadNim-e87910197a209d02cf69bba3aacd9766723aeb37.tar.gz
Check there are no side effects before optimizing away compile time expressions. (#9934)
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 04991193c..f60e2556d 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -548,6 +548,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
 
 proc semConst(c: PContext, n: PNode): PNode =
   result = copyNode(n)
+  inc c.inStaticContext
   for i in countup(0, sonsLen(n) - 1):
     var a = n.sons[i]
     if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
@@ -607,6 +608,7 @@ proc semConst(c: PContext, n: PNode): PNode =
         v.ast = def[j]
         b.sons[j] = newSymNode(v)
     addSon(result,b)
+  dec c.inStaticContext
 
 include semfields