From 6e235602fb9d7876150a0abf5c918e28db240f2a Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 3 Sep 2020 18:51:26 +0100 Subject: fix corner case in `loops` & `unused` (#4092) fixes #4091 --- test/compress/loops.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'test') diff --git a/test/compress/loops.js b/test/compress/loops.js index 878b77cb..cbc1166f 100644 --- a/test/compress/loops.js +++ b/test/compress/loops.js @@ -1037,3 +1037,54 @@ issue_4084: { } expect_stdout: "undefined" } + +issue_4091_1: { + options = { + loops: true, + toplevel: true, + unused: true, + } + input: { + try { + throw "FAIL"; + } catch (e) { + for (var e in 42); + } + console.log(e && e); + } + expect: { + try { + throw "FAIL"; + } catch (e) { + var e; + } + console.log(e && e); + } + expect_stdout: "undefined" +} + +issue_4091_2: { + options = { + loops: true, + toplevel: true, + unused: true, + } + input: { + try { + throw "FAIL"; + } catch (e) { + for (e in 42); + var e; + } + console.log(e && e); + } + expect: { + try { + throw "FAIL"; + } catch (e) { + var e; + } + console.log(e && e); + } + expect_stdout: "undefined" +} -- cgit v1.2.3