From 102f994b9d09b3ed0447f02a894fd88fcc903171 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 1 Feb 2018 15:09:53 +0800 Subject: account for declaration assignment in `collapse_vars` (#2859) fixes #2858 --- test/compress/collapse_vars.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test') diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index b3617816..f56face6 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -4190,3 +4190,37 @@ return_3: { } expect_stdout: "0" } + +issue_2858: { + options = { + collapse_vars: true, + unused: true, + } + input: { + var b; + (function() { + function f() { + a++; + } + f(); + var c = f(); + var a = void 0; + c || (b = a); + })(); + console.log(b); + } + expect: { + var b; + (function() { + function f() { + a++; + } + f(); + var c = f(); + var a = void 0; + c || (b = a); + })(); + console.log(b); + } + expect_stdout: "undefined" +} -- cgit v1.2.3