From aa664dea0a07656d1fa61263e3a03e7d8b5c4cc9 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 1 Feb 2018 16:18:29 +0800 Subject: avoid `evaluate` of compound assignment after `dead_code` transform (#2861) fixes #2860 --- test/compress/dead-code.js | 38 ++++++++++++++++++++++++++++++++++++++ test/compress/reduce_vars.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) (limited to 'test/compress') diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index b66d5ac1..9b45fe87 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -879,3 +879,41 @@ unsafe_builtin: { z; } } + +issue_2860_1: { + options = { + dead_code: true, + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + }()); + } + expect: { + console.log(function(a) { + return 1 ^ a; + }()); + } + expect_stdout: "1" +} + +issue_2860_2: { + options = { + dead_code: true, + evaluate: true, + inline: true, + passes: 2, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + }()); + } + expect: { + console.log(1); + } + expect_stdout: "1" +} diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 2e562f94..761af9e2 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -5467,3 +5467,43 @@ chained_assignments: { } expect_stdout: "5eadbeef" } + +issue_2860_1: { + options = { + dead_code: true, + evaluate: true, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + a ^= 2; + }()); + } + expect: { + console.log(function(a) { + return 1 ^ a; + }()); + } + expect_stdout: "1" +} + +issue_2860_2: { + options = { + dead_code: true, + evaluate: true, + inline: true, + passes: 2, + reduce_vars: true, + } + input: { + console.log(function(a) { + return a ^= 1; + a ^= 2; + }()); + } + expect: { + console.log(1); + } + expect_stdout: "1" +} -- cgit v1.2.3