Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix corner case in reduce_vars (#3332)
fixes #3267
  • Loading branch information
alexlamsl committed Mar 13, 2019
1 parent d4ac84b commit b052f62
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -5787,8 +5787,8 @@ merge(Compressor.prototype, {
}
if (single_use && fixed) {
def.single_use = false;
fixed._squeezed = true;
if (fixed instanceof AST_Defun) {
fixed._squeezed = true;
fixed = make_node(AST_Function, fixed, fixed);
fixed.name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
}
Expand Down
100 changes: 100 additions & 0 deletions test/compress/reduce_vars.js
Expand Up @@ -6586,3 +6586,103 @@ issue_3240_4: {
"1",
]
}

issues_3267_1: {
options = {
collapse_vars: true,
conditionals: true,
dead_code: true,
evaluate: true,
inline: true,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
(function(x) {
x();
})(function() {
(function(i) {
if (i)
return console.log("PASS");
throw "FAIL";
})(Object());
});
}
expect: {
!function(i) {
if (i)
return console.log("PASS");
throw "FAIL";
}(Object());
}
expect_stdout: "PASS"
}

issues_3267_2: {
options = {
collapse_vars: true,
conditionals: true,
dead_code: true,
evaluate: true,
inline: true,
keep_fargs: false,
passes: 2,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
(function(x) {
x();
})(function() {
(function(i) {
if (i)
return console.log("PASS");
throw "FAIL";
})(Object());
});
}
expect: {
!function() {
if (Object())
return console.log("PASS");
throw "FAIL";
}();
}
expect_stdout: "PASS"
}

issues_3267_3: {
options = {
collapse_vars: true,
conditionals: true,
dead_code: true,
evaluate: true,
inline: true,
keep_fargs: false,
passes: 2,
reduce_vars: true,
sequences: true,
side_effects: true,
unsafe: true,
unused: true,
}
input: {
(function(x) {
x();
})(function() {
(function(i) {
if (i)
return console.log("PASS");
throw "FAIL";
})(Object());
});
}
expect: {
console.log("PASS");
}
expect_stdout: "PASS"
}

0 comments on commit b052f62

Please sign in to comment.