From 4975608ae8d89fb065c59608d49b4c95eaa33d46 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sat, 14 Nov 2020 12:53:20 -0800 Subject: [PATCH] fix in opcCastIntToPtr (fixes https://github.com/flyx/NimYAML/issues/92) --- compiler/vm.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/vm.nim b/compiler/vm.nim index 696915991bd19..5bf092100ba7b 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -628,7 +628,11 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = let rb = instr.regB let typ = regs[ra].node.typ if typ.kind == tyRef: - regs[ra].node = cast[PNode](regs[rb].intVal) + template fn(val) = regs[ra].node = cast[PNode](val.intVal) + case regs[rb].kind + of rkInt: fn(regs[rb]) + of rkNode: fn(regs[rb].node) + else: stackTrace(c, tos, pc, "regs[rb].kind: " & $regs[rb].kind) else: let node2 = newNodeIT(nkIntLit, c.debug[pc], typ) case regs[rb].kind