follow #16009 VM supports cast nil to ptr (#16012)

* follow #16009 VM supports cast nil to ptr

* more testcase
This commit is contained in:
flywind 2020-11-17 18:47:01 +08:00 • committed by GitHub
commit fec19c980e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

30
tests/vm/tcastnil.nim Normal file
View file

@ -0,0 +1,30 @@
discard """
nimout: '''nil
nil
nil
nil
nil
'''
"""
block:
static:
let a = cast[pointer](nil)
echo a.repr
block:
static:
echo cast[ptr int](nil).repr
block:
const str = cast[ptr int](nil)
static:
echo str.repr
block:
static:
echo cast[ptr int](nil).repr
block:
static:
echo cast[RootRef](nil).repr