aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-08-06 01:35:11 +0100
committerGitHub <noreply@github.com>2021-08-06 08:35:11 +0800
commitfdcc6d3a9c74f55b21ceb59953ee90369d3e5e13 (patch)
tree3dfaad64dfd215873703e74a91476c6421650ca2
parent4fe2cac35ecd8fc5a69b1122cf536ee148340b3d (diff)
downloadtracifyjs-fdcc6d3a9c74f55b21ceb59953ee90369d3e5e13.tar.gz
tracifyjs-fdcc6d3a9c74f55b21ceb59953ee90369d3e5e13.zip
fix corner case in `dead_code` (#5107)
fixes #5106
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/dead-code.js36
-rw-r--r--test/jetstream.js1
3 files changed, 38 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index d5fa5663..c19091d7 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -11472,7 +11472,7 @@ merge(Compressor.prototype, {
var local = scope === compressor.find_parent(AST_Lambda);
var level = 0, node;
parent = compressor.self();
- do {
+ if (!(scope.uses_arguments && is_funarg(def)) || compressor.has_directive("use strict")) do {
node = parent;
parent = compressor.parent(level++);
if (parent instanceof AST_Assign) {
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index ecf5ce4b..389d43f8 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -1633,3 +1633,39 @@ issue_5030: {
expect_stdout: "PASS"
node_version: ">=0.12"
}
+
+issue_5106_1: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ console.log(typeof function(a) {
+ return a = arguments;
+ }("FAIL")[0]);
+ }
+ expect: {
+ console.log(typeof function(a) {
+ return a = arguments;
+ }("FAIL")[0]);
+ }
+ expect_stdout: "object"
+}
+
+issue_5106_2: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ "use strict";
+ console.log(function(a) {
+ return a = arguments;
+ }("PASS")[0]);
+ }
+ expect: {
+ "use strict";
+ console.log(function(a) {
+ return arguments;
+ }("PASS")[0]);
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/jetstream.js b/test/jetstream.js
index 9ee89291..db479d18 100644
--- a/test/jetstream.js
+++ b/test/jetstream.js
@@ -68,6 +68,7 @@ if (typeof phantom == "undefined") {
(function install() {
npm([
"install",
+ "graceful-fs@4.2.6",
"phantomjs-prebuilt@2.1.14",
"--no-audit",
"--no-optional",