From d146045ed55a45428991ece55e13afb742b2fdc4 Mon Sep 17 00:00:00 2001 From: Oscar NihlgÄrd Date: Sat, 30 Jun 2018 09:16:46 +0200 Subject: Fixes #6689 (#8135) --- compiler/vm.nim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'compiler/vm.nim') diff --git a/compiler/vm.nim b/compiler/vm.nim index c8e595f5d..9e5db978c 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1211,8 +1211,14 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = of opcIsNil: decodeB(rkInt) let node = regs[rb].node - regs[ra].intVal = ord(node.kind == nkNilLit or - (node.kind in {nkStrLit..nkTripleStrLit} and node.strVal.isNil)) + regs[ra].intVal = ord( + # Note that `nfIsRef` + `nkNilLit` represents an allocated + # reference with the value `nil`, so `isNil` should be false! + (node.kind == nkNilLit and nfIsRef notin node.flags) or + (node.kind in {nkStrLit..nkTripleStrLit} and node.strVal.isNil) or + (not node.typ.isNil and node.typ.kind == tyProc and + node.typ.callConv == ccClosure and node.sons[0].kind == nkNilLit and + node.sons[1].kind == nkNilLit)) of opcNBindSym: decodeBx(rkNode) regs[ra].node = copyTree(c.constants.sons[rbx]) -- cgit 1.4.1-2-gfad0