fix reduce_vars on AST_Arrow (#2091)

fixes #2090
This commit is contained in:
Alex Lam S.L
2017-06-14 16:40:37 +08:00
committed by GitHub
parent a7971f4e34
commit 68138f2281
2 changed files with 51 additions and 1 deletions

View File

@@ -363,7 +363,7 @@ merge(Compressor.prototype, {
safe_ids = save_ids;
return true;
}
if (node instanceof AST_Function) {
if (node instanceof AST_Function || node instanceof AST_Arrow) {
push();
var iife;
if (!node.name

View File

@@ -2537,3 +2537,53 @@ accessor: {
}
expect_stdout: "1 1"
}
issue_2090_1: {
options = {
evaluate: true,
reduce_vars: true,
}
input: {
console.log(function() {
var x = 1;
[].forEach(() => x = 2);
return x;
}());
}
expect: {
console.log(function() {
var x = 1;
[].forEach(() => x = 2);
return x;
}());
}
expect_stdout: "1"
node_version: ">=4"
}
issue_2090_2: {
options = {
evaluate: true,
reduce_vars: true,
}
input: {
console.log(function() {
var x = 1;
[].forEach(() => {
x = 2;
});
return x;
}());
}
expect: {
console.log(function() {
var x = 1;
[].forEach(() => {
x = 2;
});
return x;
}());
}
expect_stdout: "1"
node_version: ">=4"
}