Skip to content

Commit

Permalink
fix corner case in inline (#5231)
Browse files Browse the repository at this point in the history
fixes #5230
  • Loading branch information
alexlamsl committed Dec 23, 2021
1 parent 7b2eb4b commit 29a1e71
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/compress.js
Expand Up @@ -10245,7 +10245,9 @@ Compressor.prototype.compress = function(node) {
if (stat instanceof AST_LambdaDefinition) {
if (in_loop) {
var name = make_node(AST_SymbolVar, stat.name, flatten_var(stat.name));
name.definition().orig.push(name);
var def = name.definition();
def.fixed = false;
def.orig.push(name);
append_var(decls, expressions, name, to_func_expr(stat, true));
} else {
var def = stat.name.definition();
Expand Down
32 changes: 32 additions & 0 deletions test/compress/functions.js
Expand Up @@ -7071,3 +7071,35 @@ issue_5173_2: {
}
expect_stdout: "undefined"
}

issue_5230: {
options = {
collapse_vars: true,
inline: true,
merge_vars: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
}
input: {
while (function() {
function f(a) {
var b = 42, c = (console, [ a ]);
for (var k in c)
c, console.log(b++);
}
f(f);
}());
}
expect: {
while (void (f = function(c) {
var b = 42;
console;
var c;
for (var k in c = [ c ])
console.log(b++);
})(f));
var f;
}
expect_stdout: "42"
}

0 comments on commit 29a1e71

Please sign in to comment.