Skip to content

Commit

Permalink
fix corner case in functions (#4824)
Browse files Browse the repository at this point in the history
fixes #4823
  • Loading branch information
alexlamsl committed Mar 25, 2021
1 parent 03c5ecb commit 39df3a1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -6226,6 +6226,7 @@ merge(Compressor.prototype, {
&& var_defs[sym.id] == 1
&& sym.assignments == 0
&& value instanceof AST_LambdaExpression
&& !is_arguments(sym)
&& !is_arrow(value)
&& assigned_once(value, sym.references)
&& can_declare_defun(value)
Expand Down
30 changes: 30 additions & 0 deletions test/compress/functions.js
Expand Up @@ -5991,3 +5991,33 @@ issue_4788: {
}
expect_stdout: "PASS"
}

issue_4823: {
options = {
functions: true,
reduce_vars: true,
unused: true,
}
input: {
console.log(typeof function() {
{
function f() {}
var arguments = f();
function g() {}
var arguments = g;
}
return f && arguments;
}());
}
expect: {
console.log(typeof function() {
{
function f() {}
arguments = f();
var arguments = function() {};
}
return f && arguments;
}());
}
expect_stdout: "function"
}

0 comments on commit 39df3a1

Please sign in to comment.