Skip to content

Commit

Permalink
fix corner case in inline (#5284)
Browse files Browse the repository at this point in the history
fixes #5283
  • Loading branch information
alexlamsl committed Jan 10, 2022
1 parent caaa753 commit c7d2837
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -12998,6 +12998,7 @@ Compressor.prototype.compress = function(node) {
});
scope = scope.parent_scope;
}
if (!member(scope, compressor.stack)) return;
if (scope instanceof AST_Toplevel && fn.variables.size() > (arrow ? 0 : 1)) {
if (!compressor.toplevel.vars) return;
if (fn.functions.size() > 0 && !compressor.toplevel.funcs) return;
Expand Down
37 changes: 37 additions & 0 deletions test/compress/functions.js
Expand Up @@ -7977,3 +7977,40 @@ issue_5264_2: {
"baz",
]
}

issue_5283: {
options = {
if_return: true,
inline: true,
pure_getters: "strict",
side_effects: true,
unused: true,
}
input: {
var a = "FAIL 1";
(function() {
(a = "PASS")[function() {
if (console)
return null;
var b = function f(a) {
console.log("FAIL 2");
var c = a.p;
}();
}()];
})();
console.log(a);
}
expect: {
var a = "FAIL 1";
(function() {
a = "PASS";
if (!console)
(function(a) {
console.log("FAIL 2");
a.p;
})();
})();
console.log(a);
}
expect_stdout: "PASS"
}

0 comments on commit c7d2837

Please sign in to comment.