fix getNullValue for cstring in VM, make other VM code aware of nil cstring (#22527)

* fix getNullValue for cstring in VM

fixes #22524

* very ugly fixes, but fix #15730

* nil cstring len works, more test lines

* fix high

(cherry picked from commit 942f846f04)
This commit is contained in:
metagn
2023-08-21 21:08:00 +03:00
committed by narimiran
parent 562fb0d14b
commit 5fa48e97b6
4 changed files with 53 additions and 6 deletions

View File

@@ -733,3 +733,34 @@ block: # bug #22190
tab = mkOpTable(Berlin)
doAssert not tab
block: # issue #22524
const cnst = cstring(nil)
doAssert cnst.isNil
doAssert cnst == nil
let b = cnst
doAssert b.isNil
doAssert b == nil
let a = static: cstring(nil)
doAssert a.isNil
static:
var x: cstring
doAssert x.isNil
doAssert x == nil
doAssert x != ""
block: # issue #15730
const s: cstring = ""
doAssert s != nil
static:
let s: cstring = ""
doAssert not s.isNil
doAssert s != nil
doAssert s == ""
static: # more nil cstring issues
let x = cstring(nil)
doAssert x.len == 0