diff options
-rw-r--r-- | lib/compress.js | 4 | ||||
-rw-r--r-- | test/compress/varify.js | 19 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index f0453d6a..acd15f5e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -7124,7 +7124,9 @@ merge(Compressor.prototype, { var def = name.definition(); def.orig[def.orig.indexOf(node)] = name; var scope = def.scope.resolve(); - if (def.scope !== scope) scope.variables.set(def.name, def); + if (def.scope === scope) return; + def.scope = scope; + scope.variables.set(def.name, def); }), value: defn.value }); diff --git a/test/compress/varify.js b/test/compress/varify.js index 95acd032..4d2a6b5a 100644 --- a/test/compress/varify.js +++ b/test/compress/varify.js @@ -390,3 +390,22 @@ issue_4290_1_let: { expect_stdout: true node_version: ">=4" } + +drop_forin_let: { + options = { + loops: true, + toplevel: true, + unused: true, + varify: true, + } + input: { + "use strict"; + for (let a in console.log("PASS")); + } + expect: { + "use strict"; + console.log("PASS"); + } + expect_stdout: "PASS" + node_version: ">=4" +} |