From 0c4f315c026e607d00dd74ad7417344a937bf6dd Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 13 Feb 2018 01:41:22 +0800 Subject: fix corner case in `collapse_vars` (#2909) fixes #2908 --- test/compress/collapse_vars.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index ed1d8d97..2c7bbdeb 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -4517,3 +4517,32 @@ issue_2891_2: { } expect_stdout: true } + +issue_2908: { + options = { + collapse_vars: true, + } + input: { + var a = 0, b = 0; + function f(c) { + if (1 == c) return; + a++; + if (2 == c) b = a; + } + f(0); + f(2); + console.log(b); + } + expect: { + var a = 0, b = 0; + function f(c) { + if (1 == c) return; + a++; + if (2 == c) b = a; + } + f(0); + f(2); + console.log(b); + } + expect_stdout: "2" +} -- cgit v1.2.3