fix corner cases in inline (#5375)
This commit is contained in:
@@ -10524,7 +10524,7 @@ Compressor.prototype.compress = function(node) {
|
||||
insert = scope.body.indexOf(child) + 1;
|
||||
if (!insert) return false;
|
||||
if (!safe_from_await_yield(fn, avoid_await_yield(scope))) return false;
|
||||
var safe_to_inject = exp !== fn || fn.parent_scope.resolve() === scope;
|
||||
var safe_to_inject = (exp !== fn || fn.parent_scope.resolve() === scope) && !scope.pinned();
|
||||
if (scope instanceof AST_Toplevel) {
|
||||
if (compressor.toplevel.vars) {
|
||||
defined.set("arguments", true);
|
||||
@@ -13252,6 +13252,7 @@ Compressor.prototype.compress = function(node) {
|
||||
if (!(fn instanceof AST_LambdaExpression)) return;
|
||||
if (fn.name) return;
|
||||
if (fn.uses_arguments) return;
|
||||
if (fn.pinned()) return;
|
||||
if (is_generator(fn)) return;
|
||||
var arrow = is_arrow(fn);
|
||||
if (arrow && fn.value) return;
|
||||
@@ -13267,6 +13268,7 @@ Compressor.prototype.compress = function(node) {
|
||||
scope = scope.parent_scope;
|
||||
}
|
||||
if (!member(scope, compressor.stack)) return;
|
||||
if (scope.pinned() && fn.variables.size() > (arrow ? 0 : 1)) return;
|
||||
if (scope instanceof AST_Toplevel) {
|
||||
if (fn.variables.size() > (arrow ? 0 : 1)) {
|
||||
if (!compressor.toplevel.vars) return;
|
||||
|
||||
@@ -1508,6 +1508,48 @@ unsafe_call_3: {
|
||||
expect_stdout: "3"
|
||||
}
|
||||
|
||||
inline_eval_inner: {
|
||||
options = {
|
||||
inline: true,
|
||||
}
|
||||
input: {
|
||||
(function() {
|
||||
console.log(typeof eval("arguments"));
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
(function() {
|
||||
console.log(typeof eval("arguments"));
|
||||
})();
|
||||
}
|
||||
expect_stdout: "object"
|
||||
}
|
||||
|
||||
inline_eval_outer: {
|
||||
options = {
|
||||
inline: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
A = 42;
|
||||
(function(a) {
|
||||
console.log(a);
|
||||
})(A);
|
||||
console.log(eval("typeof a"));
|
||||
}
|
||||
expect: {
|
||||
A = 42;
|
||||
(function(a) {
|
||||
console.log(a);
|
||||
})(A);
|
||||
console.log(eval("typeof a"));
|
||||
}
|
||||
expect_stdout: [
|
||||
"42",
|
||||
"undefined",
|
||||
]
|
||||
}
|
||||
|
||||
issue_2616: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
|
||||
@@ -6,6 +6,7 @@ reduce_vars: {
|
||||
C: 0,
|
||||
},
|
||||
inline: true,
|
||||
passes: 2,
|
||||
reduce_funcs: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
|
||||
Reference in New Issue
Block a user