aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/js_ast.zig4
-rw-r--r--test/transpiler/transpiler.test.js22
2 files changed, 25 insertions, 1 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig
index b83f6c5c2..b5f47474a 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -2163,7 +2163,9 @@ pub const E = struct {
this.next = other;
this.end = other;
} else {
- this.end.?.next = other;
+ var end = this.end.?;
+ while (end.next != null) end = end.end.?;
+ end.next = other;
this.end = other;
}
}
diff --git a/test/transpiler/transpiler.test.js b/test/transpiler/transpiler.test.js
index 8c77dffe6..c490abb51 100644
--- a/test/transpiler/transpiler.test.js
+++ b/test/transpiler/transpiler.test.js
@@ -2807,6 +2807,28 @@ console.log(foo, array);
expectPrinted("'a' + 1", '"a" + 1');
expectPrinted("x * 'a' + 'b'", 'x * "a" + "b"');
+ // rope string push another rope string
+ expectPrinted("'a' + ('b' + 'c') + 'd'", '"abcd"');
+ expectPrinted("('a' + 'b') + 'c'", '"abc"');
+ expectPrinted("'a' + ('b' + 'c')", '"abc"');
+ expectPrinted("'a' + ('b' + ('c' + 'd')) + 'e'", '"abcde"');
+ expectPrinted("'a' + ('b' + ('c' + ('d' + 'e')))", '"abcde"');
+ expectPrinted("('a' + ('b' + ('c' + 'd'))) + 'e'", '"abcde"');
+ expectPrinted("('a' + ('b' + 'c')) + ('d' + 'e')", '"abcde"');
+ expectPrinted("('a' + 'b') + ('c' + 'd')", '"abcd"');
+ expectPrinted("'a' + ('b' + 'c') + 'd'", '"abcd"');
+ expectPrinted("'a' + ('b' + ('c' + 'd'))", '"abcd"');
+
+ function check(input, output) {
+ expect(transpiler.transformSync(input)).toEqual(output);
+ }
+
+ var output = `var boop = "bcd";\nconst ropy = "a" + boop + "d", ropy2 = "b" + boop;\n`;
+ check(`var boop = ('b' + 'c') + 'd'; const ropy = "a" + boop + 'd'; const ropy2 = 'b' + boop;`, output);
+
+ output = `var boop = "fbcd", ropy = "a" + boop + "d", ropy2 = "b" + (ropy + "d");\n`;
+ check(`var boop = "f" + ("b" + "c") + "d";var ropy = "a" + boop + "d";var ropy2 = "b" + (ropy + "d")`, output);
+
expectPrinted("'string' + `template`", `"stringtemplate"`);
expectPrinted("`template` + 'string'", '"templatestring"');