From 9c0feb69e5cdd3d491c6b0600fc964a41a774710 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 7 Oct 2020 15:01:39 +0100 Subject: fix corner case in `reduce_vars` (#4189) fixes #4188 --- test/compress/reduce_vars.js | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'test/compress/reduce_vars.js') diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 414d6646..ea3703c1 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -7535,3 +7535,69 @@ global_assign: { } expect_stdout: "PASS" } + +issue_4188_1: { + options = { + reduce_vars: true, + unused: true, + } + input: { + (function() { + try { + while (A) + var a = function() {}, b = a; + } catch (a) { + console.log(function() { + return typeof a; + }(), typeof b); + } + })(); + } + expect: { + (function() { + try { + while (A) + var a = function() {}, b = a; + } catch (a) { + console.log(function() { + return typeof a; + }(), typeof b); + } + })(); + } + expect_stdout: "object undefined" +} + +issue_4188_2: { + options = { + reduce_vars: true, + unused: true, + } + input: { + (function() { + try { + throw 42; + } catch (a) { + console.log(function() { + return typeof a; + }(), typeof b); + } + while (!console) + var a = function() {}, b = a; + })(); + } + expect: { + (function() { + try { + throw 42; + } catch (a) { + console.log(function() { + return typeof a; + }(), typeof b); + } + while (!console) + var a = function() {}, b = a; + })(); + } + expect_stdout: "number undefined" +} -- cgit v1.2.3