From 8ec331b6dd53dbf19fff615020330f5fd9501b65 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Tue, 25 Jun 2024 22:32:33 +0300 Subject: [PATCH] enhance `hoist_vars` --- lib/compress.js | 1 - test/compress/hoist_vars.js | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index 96626b3d141..816b101ef35 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -10353,7 +10353,6 @@ Compressor.prototype.compress = function(node) { def.assignments++; } def.eliminated++; - def.single_use = false; return a; }, []); if (assignments.length == 0) return null; diff --git a/test/compress/hoist_vars.js b/test/compress/hoist_vars.js index 8eb055233a9..fc75af3717c 100644 --- a/test/compress/hoist_vars.js +++ b/test/compress/hoist_vars.js @@ -228,6 +228,7 @@ issue_4489: { evaluate: true, hoist_vars: true, reduce_vars: true, + sequences: true, toplevel: true, unused: true, } @@ -363,6 +364,7 @@ issue_4893_1: { evaluate: true, hoist_vars: true, reduce_vars: true, + side_effects: true, toplevel: true, unused: true, } @@ -383,9 +385,8 @@ issue_4893_1: { } expect: { try{ - (function f() { + (function() { null.p += 42; - f; })(); } catch (e) { console.log("PASS"); @@ -422,9 +423,7 @@ issue_4893_2: { expect: { try{ (function() { - var a; - a = null; - a.p += 42; + null.p += 42; })(); } catch (e) { console.log("PASS"); @@ -610,6 +609,7 @@ issue_5411_2: { evaluate: true, hoist_vars: true, reduce_vars: true, + sequences: true, toplevel: true, unused: true, } @@ -622,9 +622,9 @@ issue_5411_2: { } expect: { var b, c; - b++; + b++, b = "PASS", - c; + c, console.log(b); } expect_stdout: "PASS"