diff options
-rw-r--r-- | compiler/jsgen.nim | 4 | ||||
-rw-r--r-- | tests/js/tmangle.nim | 4 | ||||
-rw-r--r-- | tests/js/trepr.nim | 2 | ||||
-rw-r--r-- | tests/system/tdollars.nim | 7 |
4 files changed, 11 insertions, 6 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index c4ee36dbf..6aacf818a 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1690,9 +1690,7 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope = result = putToSeq("null", indirect) of tySequence, tyString: result = putToSeq("[]", indirect) - of tyCString: - result = putToSeq("\"\"", indirect) - of tyOpt, tyProc: + of tyCString, tyOpt, tyProc: result = putToSeq("null", indirect) of tyStatic: if t.n != nil: diff --git a/tests/js/tmangle.nim b/tests/js/tmangle.nim index 393043722..caaa15fa1 100644 --- a/tests/js/tmangle.nim +++ b/tests/js/tmangle.nim @@ -62,8 +62,8 @@ block: result = result and obj1.`&&`.addr[] == "bar".cstring result = result and obj2.`if` == 0 result = result and obj2.`for` == 0 - result = result and obj2.`==`.len == 0 - result = result and obj2.`&&`.len == 0 + result = result and obj2.`==`.isNil + result = result and obj2.`&&`.isNil echo test() # Test codegen for fields with uppercase letters: diff --git a/tests/js/trepr.nim b/tests/js/trepr.nim index ffa9d4de0..eb285f70d 100644 --- a/tests/js/trepr.nim +++ b/tests/js/trepr.nim @@ -322,7 +322,7 @@ o = [Field0 = [a = "", b = @[]], Field1 = ""], p = nil, -q = ""] +q = nil] """) doAssert(repr(cc) == """ [a = 12, diff --git a/tests/system/tdollars.nim b/tests/system/tdollars.nim index 478a11b94..6ddec911f 100644 --- a/tests/system/tdollars.nim +++ b/tests/system/tdollars.nim @@ -70,3 +70,10 @@ block: # `$`(SomeInteger) testType uint64 testType int64 testType BiggestInt + +block: # #14350 for JS + var cstr: cstring + doAssert cstr == cstring(nil) + doAssert cstr == nil + doAssert cstr.isNil + doAssert cstr != cstring("") |