summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2019-06-05 14:55:47 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-06-05 14:55:47 +0200
commitefbf43d4a9b9ffdee5db95749d0d992bc16bb350 (patch)
tree31843b75327e73eb41df0e09343757246282f53b /compiler
parent92308625347493b37951cb25e944c650a909565a (diff)
downloadNim-efbf43d4a9b9ffdee5db95749d0d992bc16bb350.tar.gz
intVal works now on enum field symbols (#11403)
* intVal works now on enum field symbols

* disable flakey titerators test
Diffstat (limited to 'compiler')
-rw-r--r--compiler/vm.nim11
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 8b36b461b..4e8a34471 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -1418,9 +1418,12 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
     of opcNIntVal:
       decodeB(rkInt)
       let a = regs[rb].node
-      case a.kind
-      of nkCharLit..nkUInt64Lit: regs[ra].intVal = a.intVal
-      else: stackTrace(c, tos, pc, errFieldXNotFound & "intVal")
+      if a.kind in {nkCharLit..nkUInt64Lit}:
+        regs[ra].intVal = a.intVal
+      elif a.kind == nkSym and a.sym.kind == skEnumField:
+        regs[ra].intVal = a.sym.position
+      else:
+        stackTrace(c, tos, pc, errFieldXNotFound & "intVal")
     of opcNFloatVal:
       decodeB(rkFloat)
       let a = regs[rb].node
@@ -1692,6 +1695,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
       if dest.kind in {nkCharLit..nkUInt64Lit} and
          regs[rb].kind in {rkInt}:
         dest.intVal = regs[rb].intVal
+      elif dest.kind == nkSym and dest.sym.kind == skEnumField:
+        stackTrace(c, tos, pc, "`intVal` cannot be changed for an enum symbol.")
       else:
         stackTrace(c, tos, pc, errFieldXNotFound & "intVal")
     of opcNSetFloatVal: