From ea7829daf55f8829cc48466379cc6f6cf3394dbd Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 8 Jul 2021 09:31:04 +0100 Subject: fix corner case in `reduce_vars` (#5062) fixes #5061 --- test/compress/functions.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'test') diff --git a/test/compress/functions.js b/test/compress/functions.js index 6d41a265..7c6ebe03 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -6346,3 +6346,55 @@ issue_5046: { } expect_stdout: "PASS" } + +issue_5061_1: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + var f, a = 1; + (f = function() { + console.log(a ? "foo" : "bar"); + })(); + f(a = 0); + } + expect: { + var f, a = 1; + (f = function() { + console.log(a ? "foo" : "bar"); + })(); + f(a = 0); + } + expect_stdout: [ + "foo", + "bar", + ] +} + +issue_5061_2: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var f, a = 1; + (f = function() { + console.log(a ? "foo" : "bar"); + })(); + f(a = 0); + } + expect: { + var f, a = 1; + (f = function() { + console.log(a ? "foo" : "bar"); + })(); + f(a = 0); + } + expect_stdout: [ + "foo", + "bar", + ] +} -- cgit v1.2.3