aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js_parser/js_parser.zig4
-rw-r--r--src/js_printer.zig9
-rw-r--r--src/test/fixtures/compilation-prototype.js15
-rw-r--r--src/test/fixtures/nested-destructuring-should-print-correctly.js7
4 files changed, 28 insertions, 7 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index 22464b4da..9801e7e32 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -10855,6 +10855,8 @@ pub fn NewParser(
)) |val| {
return val;
}
+ } else {
+ e_.index = p.visitExpr(e_.index);
}
// Create an error for assigning to an import namespace when bundling. Even
@@ -12095,8 +12097,8 @@ pub fn NewParser(
// TODO: simplify boolean expression
},
.s_do_while => |data| {
- data.test_ = p.visitExpr(data.test_);
data.body = p.visitLoopBody(data.body);
+ data.test_ = p.visitExpr(data.test_);
// TODO: simplify boolean expression
},
diff --git a/src/js_printer.zig b/src/js_printer.zig
index 0940b92cb..1f43479a6 100644
--- a/src/js_printer.zig
+++ b/src/js_printer.zig
@@ -340,6 +340,7 @@ pub fn NewPrinter(
}
p.printBinding(arg.binding);
+
if (arg.default) |default| {
p.printSpace();
p.print("=");
@@ -2019,9 +2020,7 @@ pub fn NewPrinter(
continue;
}
},
- else => {
- p.printExpr(property.key, .lowest, ExprFlag.None());
- },
+ else => {},
}
} else if (p.canPrintIdentifierUTF16(str.value)) {
p.addSourceMapping(property.key.loc);
@@ -2036,9 +2035,7 @@ pub fn NewPrinter(
continue;
}
},
- else => {
- p.printExpr(property.key, .lowest, ExprFlag.None());
- },
+ else => {},
}
} else {
p.printExpr(property.key, .lowest, ExprFlag.None());
diff --git a/src/test/fixtures/compilation-prototype.js b/src/test/fixtures/compilation-prototype.js
new file mode 100644
index 000000000..6d6f8d1ef
--- /dev/null
+++ b/src/test/fixtures/compilation-prototype.js
@@ -0,0 +1,15 @@
+// The bug is:
+// when there are even number of scopes which have property accesses that themselves declare scopes,
+
+// the scope counter is wrong, causing an invariant check to fail.
+class f {}
+prop[class {}];
+class a {}
+
+// prop[class {}];
+
+// prop[
+// function (match) {
+// return 0;
+// }
+// ];
diff --git a/src/test/fixtures/nested-destructuring-should-print-correctly.js b/src/test/fixtures/nested-destructuring-should-print-correctly.js
new file mode 100644
index 000000000..072c4f93f
--- /dev/null
+++ b/src/test/fixtures/nested-destructuring-should-print-correctly.js
@@ -0,0 +1,7 @@
+function hey({
+ config: {
+ options: { ignore: e, only: t },
+ },
+}) {
+ return shouldIgnore(a, e, t, u);
+}