From b4ff6d0f2da3f094cf1bb4897a2dc67ad4f3efa5 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 26 Sep 2020 08:31:33 +0100 Subject: fix corner cases in `functions` & `merge_vars` (#4156) fixes #4155 --- test/compress/functions.js | 31 +++++++++++++++++++++++++++++++ test/compress/merge_vars.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) (limited to 'test') diff --git a/test/compress/functions.js b/test/compress/functions.js index 3027d59e..1be01167 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -4777,3 +4777,34 @@ issue_4006: { } expect_stdout: "-1" } + +issue_4155: { + options = { + functions: true, + inline: true, + merge_vars: true, + reduce_vars: true, + unused: true, + } + input: { + (function() { + var a; + (function() { + console.log(a); + })(a); + var b = function() {}; + b && console.log(typeof b); + })(); + } + expect: { + (function() { + void console.log(b); + var b = function() {}; + b && console.log(typeof b); + })(); + } + expect_stdout: [ + "undefined", + "function", + ] +} diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js index b86b0e99..7eb3f13c 100644 --- a/test/compress/merge_vars.js +++ b/test/compress/merge_vars.js @@ -2822,3 +2822,41 @@ conditional_write: { } expect_stdout: "PASS,42" } + +issue_4155: { + options = { + inline: true, + merge_vars: true, + } + input: { + (function() { + try { + throw "PASS"; + } catch (e) { + var a; + (function() { + console.log(e, a); + })(a = NaN); + } + var e = function() {}; + e && console.log(typeof e); + })(); + } + expect: { + (function() { + try { + throw "PASS"; + } catch (e) { + var a; + a = NaN, + void console.log(e, a); + } + var e = function() {}; + e && console.log(typeof e); + })(); + } + expect_stdout: [ + "PASS NaN", + "function", + ] +} -- cgit v1.2.3