Skip to content

Commit

Permalink
fix corner case in reduce_vars (#3341)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Mar 15, 2019
1 parent b66f47b commit 8b3259e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -5833,7 +5833,7 @@ merge(Compressor.prototype, {
var fn = node.fixed_value();
if (!(fn instanceof AST_Lambda)) return;
if (!fn.name) return;
if (!fixed.variables.get(fn.name.name)) return;
if (fixed.variables.get(fn.name.name) !== fn.name.definition()) return;
fn.name = fn.name.clone();
var value_def = value.variables.get(fn.name.name) || value.def_function(fn.name);
node.thedef = value_def;
Expand Down
30 changes: 30 additions & 0 deletions test/compress/reduce_vars.js
Expand Up @@ -6686,3 +6686,33 @@ issues_3267_3: {
}
expect_stdout: "PASS"
}

issue_3297: {
options = {
reduce_vars: true,
unused: true,
}
input: {
(function() {
function f() {
var a;
var b = function a() {
console.log(a === b) && f();
};
b();
}
f();
})();
}
expect: {
(function() {
(function f() {
var b = function a() {
console.log(a === b) && f();
};
b();
})();
})();
}
expect_stdout: "true"
}

0 comments on commit 8b3259e

Please sign in to comment.