aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js_ast.zig10
-rw-r--r--src/js_parser.zig3
2 files changed, 12 insertions, 1 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig
index f8adaa953..d3f908fd0 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -2526,6 +2526,16 @@ pub const Expr = struct {
}, this.loc);
}
+ pub fn canBeInlinedFromPropertyAccess(this: Expr) bool {
+ return switch (this.data) {
+ // if the array has a spread we must keep it
+ // https://github.com/oven-sh/bun/issues/2594
+ .e_spread => false,
+
+ .e_missing => false,
+ else => true,
+ };
+ }
pub fn canBeConstValue(this: Expr) bool {
return this.data.canBeConstValue();
}
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 2df6240ea..219aee8ad 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -15318,7 +15318,8 @@ fn NewParser_(
target.data.e_array.items.len == 1 and
e_.index.data == .e_number and
e_.index.data.e_number.value == 0.0 and
- e_.optional_chain == null)
+ e_.optional_chain == null and
+ target.data.e_array.items.ptr[0].canBeInlinedFromPropertyAccess())
{
return target.data.e_array.items.ptr[0];
}