From c4cebb4b01e3d1dc75da50a9e3fb05d4d342407f Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 4 May 2018 06:05:38 +0800 Subject: fix `reduce_vars` on nested invocations (#3118) --- test/compress/reduce_vars.js | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'test/compress') diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index c4308d38..1d6d1896 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -5939,3 +5939,62 @@ issue_3113_3: { } expect_stdout: "1" } + +issue_3113_4: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + var a = 0, b = 0; + function f() { + b += a; + } + f(f(), ++a); + console.log(a, b); + } + expect: { + var a = 0, b = 0; + function f() { + b += a; + } + f(f(), ++a); + console.log(a, b); + } + expect_stdout: "1 1" +} + +issue_3113_5: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + function f() { + console.log(a); + } + function g() { + f(); + } + while (g()); + var a = 1; + f(); + } + expect: { + function f() { + console.log(a); + } + function g() { + f(); + } + while (g()); + var a = 1; + f(); + } + expect_stdout: [ + "undefined", + "1", + ] +} -- cgit v1.2.3