Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix corner case in keep_fargs #3424

Merged
merged 1 commit into from May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -108,7 +108,7 @@ function Compressor(options, false_by_default) {
this.drop_fargs = keep_fargs == "strict" ? function(lambda, parent) {
if (lambda.length_read) return false;
var name = lambda.name;
if (!name) return parent && parent.TYPE == "Call";
if (!name) return parent && parent.TYPE == "Call" && parent.expression === lambda;
if (name.fixed_value() !== lambda) return false;
var def = name.definition();
if (def.direct_access) return false;
Expand Down
38 changes: 38 additions & 0 deletions test/compress/keep_fargs.js
Expand Up @@ -1117,3 +1117,41 @@ issue_3420_3: {
}
expect_stdout: "4"
}

issue_3423_1: {
options = {
keep_fargs: "strict",
unused: true,
}
input: {
function f(g) {
console.log(g.length);
}
f(function(a) {});
}
expect: {
function f(g) {
console.log(g.length);
}
f(function(a) {});
}
expect_stdout: "1"
}

issue_3423_2: {
options = {
keep_fargs: "strict",
unused: true,
}
input: {
new function(a) {
console.log(this.constructor.length);
}();
}
expect: {
new function(a) {
console.log(this.constructor.length);
}();
}
expect_stdout: "1"
}