From b267aace71def51c53617c09aa67a194f4fd5ec0 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 30 Sep 2021 22:30:32 -0700 Subject: Fix dead-code elimination edgecase with call expressions --- src/js_parser/js_parser.zig | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/js_parser/js_parser.zig') 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) { -- cgit v1.2.3