diff options
author | 2023-04-20 16:35:01 -0700 | |
---|---|---|
committer | 2023-04-20 16:35:01 -0700 | |
commit | 94cd68d7a69155fa55fd02a398e087e4e7eeaed0 (patch) | |
tree | f3a444feb2e13217629fb296d584f03ef8ca2f73 | |
parent | 6d5378566afc723e9c32b8059320fe1a8c91d354 (diff) | |
download | bun-94cd68d7a69155fa55fd02a398e087e4e7eeaed0.tar.gz bun-94cd68d7a69155fa55fd02a398e087e4e7eeaed0.tar.zst bun-94cd68d7a69155fa55fd02a398e087e4e7eeaed0.zip |
append if the previous part is not UTF8 (#2705)
-rw-r--r-- | src/js_ast.zig | 15 | ||||
-rw-r--r-- | test/bundler/transpiler.test.js | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig index 451d01a1b..2f0d8ddd6 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -2325,12 +2325,16 @@ pub const E = struct { } else { var prev_part = &parts.items[parts.items.len - 1]; - if (part.value.data.e_string.len() > 0) { - prev_part.tail.push(part.value.data.e_string); - } + if (prev_part.tail.isUTF8()) { + if (part.value.data.e_string.len() > 0) { + prev_part.tail.push(part.value.data.e_string); + } - if (part.tail.len() > 0) { - prev_part.tail.push(Expr.init(E.String, part.tail, part.tail_loc).data.e_string); + if (part.tail.len() > 0) { + prev_part.tail.push(Expr.init(E.String, part.tail, part.tail_loc).data.e_string); + } + } else { + parts.appendAssumeCapacity(part); } } } else { @@ -9825,4 +9829,3 @@ pub const UseDirective = enum { // Stmt | 192 // STry | 384 // -- ESBuild bit sizes - diff --git a/test/bundler/transpiler.test.js b/test/bundler/transpiler.test.js index cde968f80..407aaf197 100644 --- a/test/bundler/transpiler.test.js +++ b/test/bundler/transpiler.test.js @@ -2152,7 +2152,7 @@ class Foo { describe("simplification", () => { it("unary operator", () => { - expectPrinted("a = !(b, c)", "a = (b , !c)"); + expectPrinted("a = !(b, c)", "a = (b, !c)"); }); it("const inlining", () => { |