fix #17836 (typed macro isNil for proc params) (#17841)

thanks @alaviss for the test
This commit is contained in:
Saem Ghani 2021-04-25 01:30:52 -07:00 • committed by GitHub
commit 17db15f9b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View file

@ -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