@@ -13160,6 +13160,19 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function insert_assign(def, assign) {
|
||||||
|
var visited = [];
|
||||||
|
def.references.forEach(function(ref) {
|
||||||
|
var fixed = ref.fixed;
|
||||||
|
if (!fixed || !push_uniq(visited, fixed)) return;
|
||||||
|
if (fixed.assigns) {
|
||||||
|
fixed.assigns.unshift(assign);
|
||||||
|
} else {
|
||||||
|
fixed.assigns = [ assign ];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function init_ref(compressor, name) {
|
function init_ref(compressor, name) {
|
||||||
var sym = make_node(AST_SymbolRef, name, name);
|
var sym = make_node(AST_SymbolRef, name, name);
|
||||||
var assign = make_node(AST_Assign, name, {
|
var assign = make_node(AST_Assign, name, {
|
||||||
@@ -13173,16 +13186,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return assign.right;
|
return assign.right;
|
||||||
};
|
};
|
||||||
sym.fixed.assigns = [ assign ];
|
sym.fixed.assigns = [ assign ];
|
||||||
var visited = [];
|
insert_assign(def, assign);
|
||||||
def.references.forEach(function(ref) {
|
|
||||||
var fixed = ref.fixed;
|
|
||||||
if (!fixed || !push_uniq(visited, fixed)) return;
|
|
||||||
if (fixed.assigns) {
|
|
||||||
fixed.assigns.unshift(assign);
|
|
||||||
} else {
|
|
||||||
fixed.assigns = [ assign ];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
def.assignments++;
|
def.assignments++;
|
||||||
def.references.push(sym);
|
def.references.push(sym);
|
||||||
@@ -13391,12 +13395,12 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (value) body.push(make_node(AST_SimpleStatement, call, { body: value }));
|
if (value) body.push(make_node(AST_SimpleStatement, call, { body: value }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
body.push(make_node(AST_Var, call, {
|
var defn = make_node(AST_VarDef, call, {
|
||||||
definitions: [ make_node(AST_VarDef, call, {
|
|
||||||
name: argname.convert_symbol(AST_SymbolVar, process),
|
name: argname.convert_symbol(AST_SymbolVar, process),
|
||||||
value: value || make_node(AST_Undefined, call).transform(compressor),
|
value: value || make_node(AST_Undefined, call).transform(compressor),
|
||||||
}) ],
|
});
|
||||||
}));
|
if (argname instanceof AST_SymbolFunarg) insert_assign(argname.definition(), defn);
|
||||||
|
body.push(make_node(AST_Var, call, { definitions: [ defn ] }));
|
||||||
});
|
});
|
||||||
if (values.length) body.push(make_node(AST_SimpleStatement, call, {
|
if (values.length) body.push(make_node(AST_SimpleStatement, call, {
|
||||||
body: make_sequence(call, values),
|
body: make_sequence(call, values),
|
||||||
|
|||||||
@@ -8370,3 +8370,31 @@ issue_5401: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5409: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
merge_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
(a = console) || FAIL(a);
|
||||||
|
(function(b) {
|
||||||
|
console.log(b && b);
|
||||||
|
while (!console);
|
||||||
|
})();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
(a = console) || FAIL(a);
|
||||||
|
a = void 0;
|
||||||
|
console.log(a && a);
|
||||||
|
while (!console);
|
||||||
|
return;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1258,8 +1258,7 @@ issues_3267_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function() {
|
!function() {
|
||||||
var i = Object();
|
if (Object())
|
||||||
if (i)
|
|
||||||
return console.log("PASS");
|
return console.log("PASS");
|
||||||
throw "FAIL";
|
throw "FAIL";
|
||||||
}();
|
}();
|
||||||
|
|||||||
@@ -6689,8 +6689,7 @@ issues_3267_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(x) {
|
!function(x) {
|
||||||
var i = Object();
|
if (Object())
|
||||||
if (i)
|
|
||||||
return console.log("PASS");
|
return console.log("PASS");
|
||||||
throw "FAIL";
|
throw "FAIL";
|
||||||
}();
|
}();
|
||||||
|
|||||||
Reference in New Issue
Block a user