combine PR#16009 and PR#16012 (#16024)
* fix #15623 * add testcase for #15623 * add testcase * combine #16009 * support casting nil to NilableTypes in VM
This commit is contained in:
parent
0869d2a477
commit
e6e1e9574d
3 changed files with 50 additions and 1 deletions
|
|
@ -674,7 +674,7 @@ proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
|
|||
of nkCast:
|
||||
var a = getConstExpr(m, n[1], idgen, g)
|
||||
if a == nil: return
|
||||
if n.typ != nil and n.typ.kind in NilableTypes:
|
||||
if n.typ != nil and n.typ.kind in NilableTypes and a.kind != nkNilLit:
|
||||
# we allow compile-time 'cast' for pointer types:
|
||||
result = a
|
||||
result.typ = n.typ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue