From 54ec27ff9a96781501905305b6b97362f8cbfdc3 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sun, 30 May 2021 10:34:09 +0800 Subject: [PATCH] fix corner case in `hoist_props` fixes #4985 --- lib/compress.js | 3 ++- test/compress/let.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 7ea1e533..4ebee254 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -7432,7 +7432,8 @@ merge(Compressor.prototype, { && all(right.properties, can_hoist_property) && all(def.references, function(ref) { return ref.fixed_value() === right; - }); + }) + && can_drop_symbol(sym, compressor); } }); diff --git a/test/compress/let.js b/test/compress/let.js index c59308c4..023c7f63 100644 --- a/test/compress/let.js +++ b/test/compress/let.js @@ -1546,3 +1546,27 @@ issue_4848: { expect_stdout: "PASS" node_version: ">=4" } + +issue_4985: { + options = { + hoist_props: true, + reduce_vars: true, + toplevel: true, + } + input: { + "use strict"; + let a = { p: 42 }; + console.log(function() { + a; + }()); + } + expect: { + "use strict"; + let a = { p: 42 }; + console.log(function() { + a; + }()); + } + expect_stdout: "undefined" + node_version: ">=4" +}