From a84beafd1bbdb61ea5fc3662e349f6c960f1ba66 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 24 Apr 2019 02:50:15 +0800 Subject: fix corner case in `assignments` (#3376) fixes #3375 --- test/compress/assignment.js | 22 ++++++++++++++++++++++ test/compress/drop-unused.js | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'test') diff --git a/test/compress/assignment.js b/test/compress/assignment.js index ba412583..ece0185d 100644 --- a/test/compress/assignment.js +++ b/test/compress/assignment.js @@ -289,3 +289,25 @@ increment_decrement_2: { } expect_stdout: "42" } + +issue_3375: { + options = { + assignments: true, + reduce_vars: true, + } + input: { + console.log(typeof function(b) { + var a = b += 1; + --b; + return a; + }("object")); + } + expect: { + console.log(typeof function(b) { + var a = b += 1; + --b; + return a; + }("object")); + } + expect_stdout: "string" +} diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index b75c3ac5..74fe3693 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -2005,3 +2005,24 @@ issue_3233: { } expect_stdout: "PASS" } + +issue_3375: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var b = 1; + var a = c = [], c = --b + ("function" == typeof f && f()); + var a = c && c[a]; + console.log(a, b); + } + expect: { + var b = 1; + var a = [], c = --b + ("function" == typeof f && f()); + a = c && c[a]; + console.log(a, b); + } + expect_stdout: "0 0" +} -- cgit v1.2.3