From 60a400eeb03873f26145fb75880d62bea7d01d5c Mon Sep 17 00:00:00 2001 From: jangko Date: Thu, 17 Dec 2015 10:14:48 +0700 Subject: [PATCH] fixed compile time `excl ` cause SIGSEGV #3639 --- compiler/vm.nim | 2 +- tests/vm/texcl.nim | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/vm/texcl.nim diff --git a/compiler/vm.nim b/compiler/vm.nim index 0e63daf895..7207ff2239 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 0000000000..4ccfd6bfa0 --- /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