Fix implicit string to bool conversion (#567)

This commit is contained in:
Max Graey 2019-03-31 21:00:54 +03:00 committed by Daniel Wirtz
parent 85de20c4fc
commit abf3de9076
12 changed files with 1502 additions and 1399 deletions

View File

@ -141,6 +141,11 @@ export class String {
return !compareUnsafe(left, 0, right, 0, leftLength);
}
@operator.prefix("!")
private static __not(str: String): bool {
return str === null || !str.length;
}
@operator("!=")
private static __ne(left: String, right: String): bool {
return !this.__eq(left, right);

View File

@ -2348,7 +2348,7 @@
if
i32.const 0
i32.const 2072
i32.const 249
i32.const 254
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -3525,7 +3525,7 @@
if
i32.const 0
i32.const 2072
i32.const 249
i32.const 254
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -115,7 +115,7 @@
if
i32.const 0
i32.const 16
i32.const 224
i32.const 229
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -199,7 +199,7 @@
if
i32.const 0
i32.const 16
i32.const 224
i32.const 229
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -6238,7 +6238,7 @@
if
i32.const 0
i32.const 4056
i32.const 249
i32.const 254
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -11617,7 +11617,7 @@
if
i32.const 0
i32.const 4056
i32.const 249
i32.const 254
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -1525,7 +1525,7 @@
if
i32.const 0
i32.const 72
i32.const 507
i32.const 512
i32.const 8
call $~lib/env/abort
unreachable
@ -1572,7 +1572,7 @@
if
i32.const 0
i32.const 72
i32.const 511
i32.const 516
i32.const 8
call $~lib/env/abort
unreachable
@ -1651,7 +1651,7 @@
if
i32.const 0
i32.const 72
i32.const 523
i32.const 528
i32.const 8
call $~lib/env/abort
unreachable
@ -1706,7 +1706,7 @@
if
i32.const 0
i32.const 72
i32.const 532
i32.const 537
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -2008,7 +2008,7 @@
if
i32.const 0
i32.const 72
i32.const 507
i32.const 512
i32.const 8
call $~lib/env/abort
unreachable
@ -2062,7 +2062,7 @@
if
i32.const 0
i32.const 72
i32.const 511
i32.const 516
i32.const 8
call $~lib/env/abort
unreachable
@ -2157,7 +2157,7 @@
if
i32.const 0
i32.const 72
i32.const 523
i32.const 528
i32.const 8
call $~lib/env/abort
unreachable
@ -2220,7 +2220,7 @@
if
i32.const 0
i32.const 72
i32.const 532
i32.const 537
i32.const 4
call $~lib/env/abort
unreachable

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,10 @@ assert(changetype<usize>(str) == changetype<usize>("hi, I'm a string"));
assert(str.length == 16);
assert(str.charCodeAt(0) == 0x68);
assert(!!"" == false);
assert(!!"\0" == true);
assert(!!"a" == true);
assert(String.fromCharCode(0) == "\0");
assert(String.fromCharCode(54) == "6");
assert(String.fromCharCode(0x10000 + 54) == "6");

File diff suppressed because it is too large Load Diff