diff options
author | 2022-12-10 15:29:53 -0800 | |
---|---|---|
committer | 2022-12-10 15:29:53 -0800 | |
commit | b374c67c169019aeb6866cfb3e81a76ee935206b (patch) | |
tree | 6cd7fe70caa28d7cb74c377a1ad7c6f35dad260e /src | |
parent | ce960f95060ecf46bfdfd984b752bdbc72598c8d (diff) | |
download | bun-b374c67c169019aeb6866cfb3e81a76ee935206b.tar.gz bun-b374c67c169019aeb6866cfb3e81a76ee935206b.tar.zst bun-b374c67c169019aeb6866cfb3e81a76ee935206b.zip |
[transpiler] Fix bug with `===` on statically-known rope strings
Diffstat (limited to 'src')
-rw-r--r-- | src/js_ast.zig | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig index f3a10b683..4711d0e98 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -1735,13 +1735,13 @@ pub const E = struct { switch (_t) { @This() => { if (other.isUTF8()) { - return strings.eql(s.data, other.data); + return strings.eqlLong(s.data, other.data, true); } else { return strings.utf16EqlString(other.slice16(), s.data); } }, bun.string => { - return strings.eql(s.data, other); + return strings.eqlLong(s.data, other, true); }, []u16, []const u16 => { return strings.utf16EqlString(other, s.data); @@ -3769,7 +3769,11 @@ pub const Expr = struct { // Returns "equal, ok". If "ok" is false, then nothing is known about the two // values. If "ok" is true, the equality or inequality of the two values is // stored in "equal". - pub fn eql(left: Expr.Data, right: Expr.Data) Equality { + pub fn eql( + left: Expr.Data, + right: Expr.Data, + allocator: std.mem.Allocator, + ) Equality { var equality = Equality{}; switch (left) { .e_null => { @@ -3795,7 +3799,9 @@ pub const Expr = struct { .e_string => |l| { equality.ok = @as(Expr.Tag, right) == Expr.Tag.e_string; if (equality.ok) { - const r = right.e_string; + var r = right.e_string; + r.resovleRopeIfNeeded(allocator); + l.resovleRopeIfNeeded(allocator); equality.equal = r.eql(E.String, l); } }, |