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
|
|
@ -901,6 +901,11 @@ proc genCastIntFloat(c: PCtx; n: PNode; dest: var TDest) =
|
|||
c.gABx(n, opcSetType, dest, c.genType(dst))
|
||||
c.gABC(n, opcCastIntToPtr, dest, tmp)
|
||||
c.freeTemp(tmp)
|
||||
elif src.kind == tyNil and dst.kind in NilableTypes:
|
||||
# supports casting nil literals to NilableTypes in VM
|
||||
# see #16024
|
||||
if dest < 0: dest = c.getTemp(n[0].typ)
|
||||
genLit(c, n[1], dest)
|
||||
else:
|
||||
# todo: support cast from tyInt to tyRef
|
||||
globalError(c.config, n.info, "VM does not support 'cast' from " & $src.kind & " to " & $dst.kind)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue