Skip to content

Commit

Permalink
fix nested inline within loop (#3019)
Browse files Browse the repository at this point in the history
fixes #3018
  • Loading branch information
alexlamsl committed Mar 22, 2018
1 parent 5c16961 commit d1c6bb8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/compress.js
Expand Up @@ -4773,9 +4773,10 @@ merge(Compressor.prototype, {
var var_def = stat.definitions[j];
var name = var_def.name;
append_var(decls, expressions, name, var_def.value);
if (in_loop) {
if (in_loop && all(fn.argnames, function(argname) {
return argname.name != name.name;
})) {
var def = fn.variables.get(name.name);
if (def.orig[0] instanceof AST_SymbolFunarg) continue;
var sym = make_node(AST_SymbolRef, name, name);
def.references.push(sym);
expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
Expand Down
29 changes: 29 additions & 0 deletions test/compress/functions.js
Expand Up @@ -2208,3 +2208,32 @@ issue_3016_3_ie8: {
"PASS",
]
}

issue_3018: {
options = {
inline: true,
side_effects: true,
toplevel: true,
}
input: {
var b = 1, c = "PASS";
do {
(function() {
(function(a) {
a = 0 != (a && (c = "FAIL"));
})();
})();
} while (b--);
console.log(c);
}
expect: {
var b = 1, c = "PASS";
do {
a = void 0,
a = 0 != (a && (c = "FAIL"));
} while (b--);
var a;
console.log(c);
}
expect_stdout: "PASS"
}

0 comments on commit d1c6bb8

Please sign in to comment.