summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorSaem Ghani <saemghani+github@gmail.com>2021-04-25 01:30:52 -0700
committerGitHub <noreply@github.com>2021-04-25 10:30:52 +0200
commit17db15f9b1a03ac93cb6c5c0264f2b534ab8b2ab (patch)
tree6340814c50483c36b4e6905f8ac9d4b00123951e /compiler
parentffe4328b3513617be0d27c773d59bea441ec1c65 (diff)
downloadNim-17db15f9b1a03ac93cb6c5c0264f2b534ab8b2ab.tar.gz
fix #17836 (typed macro isNil for proc params) (#17841)
thanks @alaviss for the test
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ast.nim4
-rw-r--r--compiler/vm.nim4
2 files changed, 6 insertions, 2 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 02a2ae7a4..7090bc7ee 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1171,6 +1171,7 @@ when defined(useNodeIds):
   var gNodeId: int
 
 proc newNode*(kind: TNodeKind): PNode =
+  ## new node with unknown line info, no type, and no children
   result = PNode(kind: kind, info: unknownLineInfo)
   when defined(useNodeIds):
     result.id = gNodeId
@@ -1180,6 +1181,7 @@ proc newNode*(kind: TNodeKind): PNode =
     inc gNodeId
 
 proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode =
+  ## new node with line info, no type, and no children
   result = PNode(kind: kind, info: info)
   when defined(useNodeIds):
     result.id = gNodeId
@@ -1189,6 +1191,7 @@ proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode =
     inc gNodeId
 
 proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode =
+  ## new node with line info, type, and children
   result = PNode(kind: kind, info: info)
   if children > 0:
     newSeq(result.sons, children)
@@ -1200,6 +1203,7 @@ proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode =
     inc gNodeId
 
 proc newNodeIT*(kind: TNodeKind, info: TLineInfo, typ: PType): PNode =
+  ## new node with line info, type, and no children
   result = newNode(kind)
   result.info = info
   result.typ = typ
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 7a231a482..19ccea55b 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -1513,8 +1513,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
         # reference with the value `nil`, so `isNil` should be false!
         (node.kind == nkNilLit and nfIsRef notin node.flags) or
         (not node.typ.isNil and node.typ.kind == tyProc and
-          node.typ.callConv == ccClosure and node[0].kind == nkNilLit and
-          node[1].kind == nkNilLit))
+          node.typ.callConv == ccClosure and node.safeLen > 0 and
+          node[0].kind == nkNilLit and node[1].kind == nkNilLit))
     of opcNBindSym:
       # cannot use this simple check
       # if dynamicBindSym notin c.config.features: