summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorjangko <jangko128@gmail.com>2015-12-17 10:14:48 +0700
committerjangko <jangko128@gmail.com>2015-12-17 10:14:48 +0700
commit60a400eeb03873f26145fb75880d62bea7d01d5c (patch)
tree26ab1f23cac9110f70d4299a9692c91119cde3f9
parenta3c8bb93760e258de406572f6181aa18fc88e7c3 (diff)
downloadNim-60a400eeb03873f26145fb75880d62bea7d01d5c.tar.gz
fixed compile time `excl ` cause SIGSEGV #3639
-rw-r--r--compiler/vm.nim2
-rw-r--r--tests/vm/texcl.nim27
2 files changed, 28 insertions, 1 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 0e63daf89..7207ff223 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -611,7 +611,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
       addSon(regs[ra].node, r.copyTree)
     of opcExcl:
       decodeB(rkNode)
-      var b = newNodeIT(nkCurly, regs[rb].node.info, regs[rb].node.typ)
+      var b = newNodeIT(nkCurly, regs[ra].node.info, regs[ra].node.typ)
       addSon(b, regs[rb].regToNode)
       var r = diffSets(regs[ra].node, b)
       discardSons(regs[ra].node)
diff --git a/tests/vm/texcl.nim b/tests/vm/texcl.nim
new file mode 100644
index 000000000..4ccfd6bfa
--- /dev/null
+++ b/tests/vm/texcl.nim
@@ -0,0 +1,27 @@
+discard """
+  output: '''false'''
+"""
+
+import macros
+
+type
+  nlOptions = enum
+    nloNone
+    nloDebug
+
+var nlOpts {.compileTime.} = {nloDebug}
+
+proc initOpts(): set[nlOptions] =
+  result.incl nloDebug
+  result.incl nloNone
+  result.excl nloDebug
+  
+const cOpts = initOpts()
+
+macro nlo(): stmt =
+  nlOpts.incl(nloNone)
+  nlOpts.excl(nloDebug)
+  result = newEmptyNode()
+
+nlo()
+echo nloDebug in cOpts
\ No newline at end of file