@@ -12901,43 +12901,44 @@ Compressor.prototype.compress = function(node) {
|
|||||||
AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
|
AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
|
||||||
if (!compressor.option("properties")) return;
|
if (!compressor.option("properties")) return;
|
||||||
if (key === "__proto__") return;
|
if (key === "__proto__") return;
|
||||||
var expr = this.expression;
|
var self = this;
|
||||||
if (expr instanceof AST_Object) {
|
var expr = self.expression;
|
||||||
var props = expr.properties;
|
if (!(expr instanceof AST_Object)) return;
|
||||||
for (var i = props.length; --i >= 0;) {
|
var props = expr.properties;
|
||||||
var prop = props[i];
|
for (var i = props.length; --i >= 0;) {
|
||||||
if (prop.key !== key) continue;
|
var prop = props[i];
|
||||||
if (!all(props, can_hoist_property)) return;
|
if (prop.key !== key) continue;
|
||||||
if (!safe_to_flatten(prop.value, compressor)) return;
|
if (!all(props, can_hoist_property)) return;
|
||||||
var scope, values = [];
|
if (!safe_to_flatten(prop.value, compressor)) return;
|
||||||
for (var j = 0; j < props.length; j++) {
|
var call, scope, values = [];
|
||||||
var value = props[j].value;
|
for (var j = 0; j < props.length; j++) {
|
||||||
if (props[j] instanceof AST_ObjectMethod) {
|
var value = props[j].value;
|
||||||
var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this());
|
if (props[j] instanceof AST_ObjectMethod) {
|
||||||
if (arrow) {
|
var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this());
|
||||||
if (!scope) scope = compressor.find_parent(AST_Scope);
|
if (arrow) {
|
||||||
var avoid = avoid_await_yield(scope);
|
if (!scope) scope = compressor.find_parent(AST_Scope);
|
||||||
value.each_argname(function(argname) {
|
var avoid = avoid_await_yield(scope);
|
||||||
if (avoid[argname.name]) arrow = false;
|
value.each_argname(function(argname) {
|
||||||
});
|
if (avoid[argname.name]) arrow = false;
|
||||||
}
|
});
|
||||||
var ctor;
|
|
||||||
if (arrow) {
|
|
||||||
ctor = is_async(value) ? AST_AsyncArrow : AST_Arrow;
|
|
||||||
} else if (i === j && !(compressor.parent() instanceof AST_Call)) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
ctor = value.CTOR;
|
|
||||||
}
|
|
||||||
value = make_node(ctor, value, value);
|
|
||||||
}
|
}
|
||||||
values.push(value);
|
var ctor;
|
||||||
|
if (arrow) {
|
||||||
|
ctor = is_async(value) ? AST_AsyncArrow : AST_Arrow;
|
||||||
|
} else if (i != j
|
||||||
|
|| (call = compressor.parent()) instanceof AST_Call && call.expression === self) {
|
||||||
|
ctor = value.CTOR;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
value = make_node(ctor, value, value);
|
||||||
}
|
}
|
||||||
return make_node(AST_Sub, this, {
|
values.push(value);
|
||||||
expression: make_node(AST_Array, expr, { elements: values }),
|
|
||||||
property: make_node(AST_Number, this, { value: i }),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
return make_node(AST_Sub, self, {
|
||||||
|
expression: make_node(AST_Array, expr, { elements: values }),
|
||||||
|
property: make_node(AST_Number, self, { value: i }),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2502,3 +2502,39 @@ issue_5352: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=12"
|
node_version: ">=12"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5387: {
|
||||||
|
options = {
|
||||||
|
properties: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(function(a) {
|
||||||
|
try {
|
||||||
|
class A extends a {}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
})({
|
||||||
|
f() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}.f);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
(function(a) {
|
||||||
|
try {
|
||||||
|
class A extends a {}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
})({
|
||||||
|
f() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}.f);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user