diff options
author | 2021-09-30 22:30:32 -0700 | |
---|---|---|
committer | 2021-09-30 22:30:32 -0700 | |
commit | b267aace71def51c53617c09aa67a194f4fd5ec0 (patch) | |
tree | 7dcbc76ace40f1998e25f6e924e5962da7c214ae | |
parent | b4bd8e416996b3846319a82270b38415b9a5b61a (diff) | |
download | bun-b267aace71def51c53617c09aa67a194f4fd5ec0.tar.gz bun-b267aace71def51c53617c09aa67a194f4fd5ec0.tar.zst bun-b267aace71def51c53617c09aa67a194f4fd5ec0.zip |
Fix dead-code elimination edgecase with call expressions
-rw-r--r-- | src/js_parser/js_parser.zig | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index cb3e0ff0c..63ca64b01 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -1030,7 +1030,9 @@ pub const SideEffects = enum(u2) { // A call that has been marked "__PURE__" can be removed if all arguments // can be removed. The annotation causes us to ignore the target. if (call.can_be_unwrapped_if_unused) { - return Expr.joinAllWithCommaCallback(call.args, @TypeOf(p), p, simpifyUnusedExpr, p.allocator); + if (call.args.len > 0) { + return Expr.joinAllWithCommaCallback(call.args, @TypeOf(p), p, simpifyUnusedExpr, p.allocator); + } } }, @@ -1077,7 +1079,9 @@ pub const SideEffects = enum(u2) { // A constructor call that has been marked "__PURE__" can be removed if all arguments // can be removed. The annotation causes us to ignore the target. if (call.can_be_unwrapped_if_unused) { - return Expr.joinAllWithComma(call.args, p.allocator); + if (call.args.len > 0) { + return Expr.joinAllWithComma(call.args, p.allocator); + } } }, else => {}, @@ -12548,9 +12552,8 @@ pub fn NewParser( return false; } } + return true; } - - return true; }, .e_new => |ex| { @@ -12562,9 +12565,9 @@ pub fn NewParser( return false; } } - } - return true; + return true; + } }, .e_unary => |ex| { switch (ex.op) { |