From 2cff7c94e843e72dee1adf6c826a190f0e156441 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 14 May 2021 18:49:46 +0100 Subject: fix corner case in `reduce_vars` (#4934) fixes #4933 --- test/compress/varify.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'test/compress') diff --git a/test/compress/varify.js b/test/compress/varify.js index f60c5474..75d50e6d 100644 --- a/test/compress/varify.js +++ b/test/compress/varify.js @@ -523,3 +523,55 @@ default_init: { expect_stdout: "PASS" node_version: ">=4" } + +issue_4933_1: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + varify: true, + } + input: { + console.log(f()); + function f() { + var a; + for (console in a = [ f ]) { + const b = a; + } + } + } + expect: { + console.log(function f() { + var a; + for (console in a = [ f ]) { + const b = a; + } + }()); + } + expect_stdout: "undefined" +} + +issue_4933_2: { + options = { + passes: 2, + reduce_vars: true, + toplevel: true, + unused: true, + varify: true, + } + input: { + console.log(f()); + function f() { + var a; + for (console in a = [ f ]) { + const b = a; + } + } + } + expect: { + console.log(function f() { + for (console in [ f ]); + }()); + } + expect_stdout: "undefined" +} -- cgit v1.2.3