@@ -13160,6 +13160,19 @@ Compressor.prototype.compress = function(node) {
|
||||
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) {
|
||||
var sym = make_node(AST_SymbolRef, name, name);
|
||||
var assign = make_node(AST_Assign, name, {
|
||||
@@ -13173,16 +13186,7 @@ Compressor.prototype.compress = function(node) {
|
||||
return assign.right;
|
||||
};
|
||||
sym.fixed.assigns = [ 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 ];
|
||||
}
|
||||
});
|
||||
insert_assign(def, assign);
|
||||
}
|
||||
def.assignments++;
|
||||
def.references.push(sym);
|
||||
@@ -13391,12 +13395,12 @@ Compressor.prototype.compress = function(node) {
|
||||
if (value) body.push(make_node(AST_SimpleStatement, call, { body: value }));
|
||||
return;
|
||||
}
|
||||
body.push(make_node(AST_Var, call, {
|
||||
definitions: [ make_node(AST_VarDef, call, {
|
||||
name: argname.convert_symbol(AST_SymbolVar, process),
|
||||
value: value || make_node(AST_Undefined, call).transform(compressor),
|
||||
}) ],
|
||||
}));
|
||||
var defn = make_node(AST_VarDef, call, {
|
||||
name: argname.convert_symbol(AST_SymbolVar, process),
|
||||
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, {
|
||||
body: make_sequence(call, values),
|
||||
|
||||
@@ -8370,3 +8370,31 @@ issue_5401: {
|
||||
}
|
||||
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: {
|
||||
!function() {
|
||||
var i = Object();
|
||||
if (i)
|
||||
if (Object())
|
||||
return console.log("PASS");
|
||||
throw "FAIL";
|
||||
}();
|
||||
|
||||
@@ -6689,8 +6689,7 @@ issues_3267_1: {
|
||||
}
|
||||
expect: {
|
||||
!function(x) {
|
||||
var i = Object();
|
||||
if (i)
|
||||
if (Object())
|
||||
return console.log("PASS");
|
||||
throw "FAIL";
|
||||
}();
|
||||
|
||||
Reference in New Issue
Block a user