* fix #14350, cstrings in JS init as null
This commit is contained in:
parent
278b4582f5
commit
80c360fceb
4 changed files with 11 additions and 6 deletions
|
|
@ -1690,9 +1690,7 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope =
|
||||||
result = putToSeq("null", indirect)
|
result = putToSeq("null", indirect)
|
||||||
of tySequence, tyString:
|
of tySequence, tyString:
|
||||||
result = putToSeq("[]", indirect)
|
result = putToSeq("[]", indirect)
|
||||||
of tyCString:
|
of tyCString, tyOpt, tyProc:
|
||||||
result = putToSeq("\"\"", indirect)
|
|
||||||
of tyOpt, tyProc:
|
|
||||||
result = putToSeq("null", indirect)
|
result = putToSeq("null", indirect)
|
||||||
of tyStatic:
|
of tyStatic:
|
||||||
if t.n != nil:
|
if t.n != nil:
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,8 @@ block:
|
||||||
result = result and obj1.`&&`.addr[] == "bar".cstring
|
result = result and obj1.`&&`.addr[] == "bar".cstring
|
||||||
result = result and obj2.`if` == 0
|
result = result and obj2.`if` == 0
|
||||||
result = result and obj2.`for` == 0
|
result = result and obj2.`for` == 0
|
||||||
result = result and obj2.`==`.len == 0
|
result = result and obj2.`==`.isNil
|
||||||
result = result and obj2.`&&`.len == 0
|
result = result and obj2.`&&`.isNil
|
||||||
echo test()
|
echo test()
|
||||||
|
|
||||||
# Test codegen for fields with uppercase letters:
|
# Test codegen for fields with uppercase letters:
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ o = [Field0 = [a = "",
|
||||||
b = @[]],
|
b = @[]],
|
||||||
Field1 = ""],
|
Field1 = ""],
|
||||||
p = nil,
|
p = nil,
|
||||||
q = ""]
|
q = nil]
|
||||||
""")
|
""")
|
||||||
doAssert(repr(cc) == """
|
doAssert(repr(cc) == """
|
||||||
[a = 12,
|
[a = 12,
|
||||||
|
|
|
||||||
|
|
@ -70,3 +70,10 @@ block: # `$`(SomeInteger)
|
||||||
testType uint64
|
testType uint64
|
||||||
testType int64
|
testType int64
|
||||||
testType BiggestInt
|
testType BiggestInt
|
||||||
|
|
||||||
|
block: # #14350 for JS
|
||||||
|
var cstr: cstring
|
||||||
|
doAssert cstr == cstring(nil)
|
||||||
|
doAssert cstr == nil
|
||||||
|
doAssert cstr.isNil
|
||||||
|
doAssert cstr != cstring("")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue