mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-01 17:41:17 +00:00
fixes #922
This commit is contained in:
@@ -321,9 +321,18 @@ proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) =
|
||||
c.gen(n.sons[2], dest)
|
||||
c.patch(L1)
|
||||
|
||||
proc nilLiteral(n: PNode): PNode =
|
||||
if n.kind == nkNilLit and n.typ.sym != nil and
|
||||
n.typ.sym.magic == mPNimrodNode:
|
||||
let nilo = newNodeIT(nkNilLit, n.info, n.typ)
|
||||
result = newNodeIT(nkMetaNode, n.info, n.typ)
|
||||
result.add nilo
|
||||
else:
|
||||
result = n
|
||||
|
||||
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
||||
result = c.constants.len
|
||||
c.constants.add n
|
||||
c.constants.add n.nilLiteral
|
||||
internalAssert result < 0x7fff
|
||||
|
||||
proc sameConstant*(a, b: PNode): bool =
|
||||
@@ -1109,7 +1118,12 @@ proc getNullValue(typ: PType, info: TLineInfo): PNode =
|
||||
result = newNodeIT(nkFloatLit, info, t)
|
||||
of tyVar, tyPointer, tyPtr, tyCString, tySequence, tyString, tyExpr,
|
||||
tyStmt, tyTypeDesc, tyStatic, tyRef:
|
||||
result = newNodeIT(nkNilLit, info, t)
|
||||
if t.sym != nil and t.sym.magic == mPNimrodNode:
|
||||
let nilo = newNodeIT(nkNilLit, info, t)
|
||||
result = newNodeIT(nkMetaNode, info, t)
|
||||
result.add nilo
|
||||
else:
|
||||
result = newNodeIT(nkNilLit, info, t)
|
||||
of tyProc:
|
||||
if t.callConv != ccClosure:
|
||||
result = newNodeIT(nkNilLit, info, t)
|
||||
|
||||
Reference in New Issue
Block a user