aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser.zig
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-01-23 15:57:47 -0800
committerGravatar GitHub <noreply@github.com> 2023-01-23 15:57:47 -0800
commitf5cda8ff1871571e3a6e655326fcda56e65e0dfb (patch)
treee80306dad7c0043877eb3da4b6287a60c4b88766 /src/js_parser.zig
parent4570ff77807a334f7bcd23e4b69b758d365b82a0 (diff)
downloadbun-f5cda8ff1871571e3a6e655326fcda56e65e0dfb.tar.gz
bun-f5cda8ff1871571e3a6e655326fcda56e65e0dfb.tar.zst
bun-f5cda8ff1871571e3a6e655326fcda56e65e0dfb.zip
fix constructor statement order (#1883)
* leave super alone * more tests
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r--src/js_parser.zig21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig
index a745da798..ab9c9bec6 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -14718,7 +14718,7 @@ fn NewParser_(
}
// This might be wrong.
- _ = p.visitClass(expr.loc, e_, true);
+ _ = p.visitClass(expr.loc, e_);
},
else => {},
}
@@ -15773,7 +15773,7 @@ fn NewParser_(
return;
},
.s_class => |class| {
- _ = p.visitClass(s2.loc, &class.class, false);
+ _ = p.visitClass(s2.loc, &class.class);
if (p.is_control_flow_dead)
return;
@@ -16277,7 +16277,7 @@ fn NewParser_(
}
}
- _ = p.visitClass(stmt.loc, &data.class, false);
+ _ = p.visitClass(stmt.loc, &data.class);
// Remove the export flag inside a namespace
const was_export_inside_namespace = data.is_export and p.enclosing_namespace_arg_ref != null;
@@ -17095,12 +17095,6 @@ fn NewParser_(
const i = if (super_index) |j| j + 1 else 0;
constructor_stmts.insertSlice(i, instance_members.items) catch unreachable;
- // move super behind statements generated from parameter properties
- if (super_index) |j| {
- const super = constructor_stmts.orderedRemove(j);
- constructor_stmts.insert(0, super) catch unreachable;
- }
-
constructor_function.?.func.body.stmts = constructor_stmts.items;
}
}
@@ -17437,7 +17431,7 @@ fn NewParser_(
return res;
}
- fn visitClass(p: *P, name_scope_loc: logger.Loc, class: *G.Class, comptime is_expr: bool) Ref {
+ fn visitClass(p: *P, name_scope_loc: logger.Loc, class: *G.Class) Ref {
if (only_scan_imports_and_do_not_visit) {
@compileError("only_scan_imports_and_do_not_visit must not run this.");
}
@@ -17592,7 +17586,7 @@ fn NewParser_(
// if this is an expression, we can move statements after super() because there will be 0 decorators
var super_index: ?usize = null;
- if (comptime is_expr and class.extends != null) {
+ if (class.extends != null) {
for (constructor.func.body.stmts) |stmt, index| {
if (stmt.data != .s_expr or stmt.data.s_expr.value.data != .e_call or stmt.data.s_expr.value.data.e_call.target.data != .e_super) continue;
super_index = index;
@@ -17615,10 +17609,7 @@ fn NewParser_(
const name = p.symbols.items[id.ref.innerIndex()].original_name;
const ident = p.newExpr(E.Identifier{ .ref = id.ref }, arg.binding.loc);
- if (comptime is_expr) {
- if (super_index) |k| j += k + 1;
- }
- stmts.insert(j, Expr.assignStmt(
+ stmts.insert(if (super_index) |k| j + k + 1 else j, Expr.assignStmt(
p.newExpr(E.Dot{
.target = p.newExpr(E.This{}, arg.binding.loc),
.name = name,