thanks @alaviss for the test
This commit is contained in:
parent
ffe4328b35
commit
17db15f9b1
3 changed files with 21 additions and 2 deletions
|
|
@ -1171,6 +1171,7 @@ when defined(useNodeIds):
|
||||||
var gNodeId: int
|
var gNodeId: int
|
||||||
|
|
||||||
proc newNode*(kind: TNodeKind): PNode =
|
proc newNode*(kind: TNodeKind): PNode =
|
||||||
|
## new node with unknown line info, no type, and no children
|
||||||
result = PNode(kind: kind, info: unknownLineInfo)
|
result = PNode(kind: kind, info: unknownLineInfo)
|
||||||
when defined(useNodeIds):
|
when defined(useNodeIds):
|
||||||
result.id = gNodeId
|
result.id = gNodeId
|
||||||
|
|
@ -1180,6 +1181,7 @@ proc newNode*(kind: TNodeKind): PNode =
|
||||||
inc gNodeId
|
inc gNodeId
|
||||||
|
|
||||||
proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode =
|
proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode =
|
||||||
|
## new node with line info, no type, and no children
|
||||||
result = PNode(kind: kind, info: info)
|
result = PNode(kind: kind, info: info)
|
||||||
when defined(useNodeIds):
|
when defined(useNodeIds):
|
||||||
result.id = gNodeId
|
result.id = gNodeId
|
||||||
|
|
@ -1189,6 +1191,7 @@ proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode =
|
||||||
inc gNodeId
|
inc gNodeId
|
||||||
|
|
||||||
proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode =
|
proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode =
|
||||||
|
## new node with line info, type, and children
|
||||||
result = PNode(kind: kind, info: info)
|
result = PNode(kind: kind, info: info)
|
||||||
if children > 0:
|
if children > 0:
|
||||||
newSeq(result.sons, children)
|
newSeq(result.sons, children)
|
||||||
|
|
@ -1200,6 +1203,7 @@ proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode =
|
||||||
inc gNodeId
|
inc gNodeId
|
||||||
|
|
||||||
proc newNodeIT*(kind: TNodeKind, info: TLineInfo, typ: PType): PNode =
|
proc newNodeIT*(kind: TNodeKind, info: TLineInfo, typ: PType): PNode =
|
||||||
|
## new node with line info, type, and no children
|
||||||
result = newNode(kind)
|
result = newNode(kind)
|
||||||
result.info = info
|
result.info = info
|
||||||
result.typ = typ
|
result.typ = typ
|
||||||
|
|
|
||||||
|
|
@ -1513,8 +1513,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
# reference with the value `nil`, so `isNil` should be false!
|
# reference with the value `nil`, so `isNil` should be false!
|
||||||
(node.kind == nkNilLit and nfIsRef notin node.flags) or
|
(node.kind == nkNilLit and nfIsRef notin node.flags) or
|
||||||
(not node.typ.isNil and node.typ.kind == tyProc and
|
(not node.typ.isNil and node.typ.kind == tyProc and
|
||||||
node.typ.callConv == ccClosure and node[0].kind == nkNilLit and
|
node.typ.callConv == ccClosure and node.safeLen > 0 and
|
||||||
node[1].kind == nkNilLit))
|
node[0].kind == nkNilLit and node[1].kind == nkNilLit))
|
||||||
of opcNBindSym:
|
of opcNBindSym:
|
||||||
# cannot use this simple check
|
# cannot use this simple check
|
||||||
# if dynamicBindSym notin c.config.features:
|
# if dynamicBindSym notin c.config.features:
|
||||||
|
|
|
||||||
15
tests/macros/t17836.nim
Normal file
15
tests/macros/t17836.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import macros
|
||||||
|
|
||||||
|
# Ensure that `isNil` works in the typed macro context when pass procs.
|
||||||
|
|
||||||
|
type
|
||||||
|
O = object
|
||||||
|
fn: proc(i: int): int
|
||||||
|
|
||||||
|
var o: O
|
||||||
|
|
||||||
|
macro typedBug(expr: typed) =
|
||||||
|
doAssert expr[1] != nil
|
||||||
|
doAssert not expr[1].isNil
|
||||||
|
|
||||||
|
typedBug(o.fn)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue