@@ -189,6 +189,10 @@ Compressor.prototype = new TreeTransformer(function(node, descend, in_list) {
|
||||
if (node._squeezed) return node;
|
||||
var is_scope = node instanceof AST_Scope;
|
||||
if (is_scope) {
|
||||
if (this.option("arrows") && is_arrow(node) && node.value) {
|
||||
node.body = [ node.first_statement() ];
|
||||
node.value = null;
|
||||
}
|
||||
node.hoist_properties(this);
|
||||
node.hoist_declarations(this);
|
||||
node.process_returns(this);
|
||||
@@ -8449,6 +8453,7 @@ Compressor.prototype.compress = function(node) {
|
||||
AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
|
||||
if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return;
|
||||
var self = this;
|
||||
if (is_arrow(self) && self.value) return;
|
||||
var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
|
||||
var defs_by_id = Object.create(null);
|
||||
var tt = new TreeTransformer(function(node, descend) {
|
||||
@@ -8486,18 +8491,9 @@ Compressor.prototype.compress = function(node) {
|
||||
return make_sequence(node, assignments);
|
||||
}
|
||||
if (node instanceof AST_Scope) {
|
||||
var parent;
|
||||
if (node === self || (parent = tt.parent()).TYPE == "Call" && parent.expression === node) {
|
||||
if (!(is_arrow(node) && node.value)) return;
|
||||
var stat = node.first_statement();
|
||||
node.body = [ stat ];
|
||||
node.value = null;
|
||||
descend(node, tt);
|
||||
if (node.body.length == 1 && node.body[0] === stat) {
|
||||
node.body.length = 0;
|
||||
node.value = stat.value;
|
||||
}
|
||||
}
|
||||
if (node === self) return;
|
||||
var parent = tt.parent();
|
||||
if (parent.TYPE == "Call" && parent.expression === node) return;
|
||||
return node;
|
||||
}
|
||||
if (node instanceof AST_VarDef) {
|
||||
|
||||
@@ -668,6 +668,28 @@ single_use_recursive: {
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
inline_iife_within_arrow: {
|
||||
options = {
|
||||
arrows: true,
|
||||
inline: true,
|
||||
}
|
||||
input: {
|
||||
var f = () => console.log(function(a) {
|
||||
return Math.ceil(a);
|
||||
}(Math.random()));
|
||||
f();
|
||||
}
|
||||
expect: {
|
||||
var f = () => {
|
||||
return console.log((a = Math.random(), Math.ceil(a)));
|
||||
var a;
|
||||
};
|
||||
f();
|
||||
}
|
||||
expect_stdout: "1"
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
issue_4388: {
|
||||
options = {
|
||||
inline: true,
|
||||
|
||||
Reference in New Issue
Block a user