@@ -10515,16 +10515,8 @@ Compressor.prototype.compress = function(node) {
|
|||||||
append_var(decl_var, expr_var, name, value);
|
append_var(decl_var, expr_var, name, value);
|
||||||
if (!in_loop) continue;
|
if (!in_loop) continue;
|
||||||
if (arg_used.has(name.name)) continue;
|
if (arg_used.has(name.name)) continue;
|
||||||
var def = name.definition();
|
if (name.definition().orig.length == 1 && fn.functions.has(name.name)) continue;
|
||||||
if (def.orig.length == 1 && fn.functions.has(name.name)) continue;
|
expr_loop.push(init_ref(compressor, name));
|
||||||
var sym = make_node(AST_SymbolRef, name, name);
|
|
||||||
def.assignments++;
|
|
||||||
def.references.push(sym);
|
|
||||||
expr_loop.push(make_node(AST_Assign, var_def, {
|
|
||||||
operator: "=",
|
|
||||||
left: sym,
|
|
||||||
right: make_node(AST_Undefined, name),
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
[].push.apply(decls, decl_var);
|
[].push.apply(decls, decl_var);
|
||||||
@@ -13001,6 +12993,22 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function init_ref(compressor, name) {
|
||||||
|
var sym = make_node(AST_SymbolRef, name, name);
|
||||||
|
var def = name.definition();
|
||||||
|
def.assignments++;
|
||||||
|
def.references.push(sym);
|
||||||
|
var assign = make_node(AST_Assign, name, {
|
||||||
|
operator: "=",
|
||||||
|
left: sym,
|
||||||
|
right: make_node(AST_Undefined, name).transform(compressor),
|
||||||
|
});
|
||||||
|
sym.fixed = function() {
|
||||||
|
return assign.right;
|
||||||
|
};
|
||||||
|
return assign;
|
||||||
|
}
|
||||||
|
|
||||||
(function(def) {
|
(function(def) {
|
||||||
def(AST_Node, noop);
|
def(AST_Node, noop);
|
||||||
def(AST_Assign, noop);
|
def(AST_Assign, noop);
|
||||||
@@ -13183,17 +13191,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
})) return;
|
})) return;
|
||||||
var sym = def.orig[0];
|
var sym = def.orig[0];
|
||||||
if (sym instanceof AST_SymbolCatch) return;
|
if (sym instanceof AST_SymbolCatch) return;
|
||||||
var ref = make_node(AST_SymbolRef, sym, flatten_var(sym));
|
body.push(make_node(AST_SimpleStatement, sym, { body: init_ref(compressor, flatten_var(sym)) }));
|
||||||
def = ref.definition();
|
|
||||||
def.assignments++;
|
|
||||||
def.references.push(ref);
|
|
||||||
body.push(make_node(AST_SimpleStatement, sym, {
|
|
||||||
body: make_node(AST_Assign, sym, {
|
|
||||||
operator: "=",
|
|
||||||
left: ref,
|
|
||||||
right: make_node(AST_Undefined, sym).transform(compressor),
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
if (fn.variables.has("NaN")) scope.transform(new TreeTransformer(function(node) {
|
if (fn.variables.has("NaN")) scope.transform(new TreeTransformer(function(node) {
|
||||||
if (node instanceof AST_NaN) return make_node(AST_Binary, node, {
|
if (node instanceof AST_NaN) return make_node(AST_Binary, node, {
|
||||||
|
|||||||
@@ -8084,3 +8084,53 @@ issue_5296: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5316_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
do {
|
||||||
|
console.log("PASS");
|
||||||
|
} while (function() {
|
||||||
|
var a, b = 42 && (console[a = b] = a++);
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
do {
|
||||||
|
console.log("PASS");
|
||||||
|
} while (b = a = void 0, b = (42, console[a = a] = a++), void 0);
|
||||||
|
var a, b;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5316_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
do {
|
||||||
|
(function() {
|
||||||
|
var a, b = 42 && (console[a = b] = a++);
|
||||||
|
while (console.log("PASS"));
|
||||||
|
})();
|
||||||
|
} while (!console);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
do {
|
||||||
|
a = void 0;
|
||||||
|
var a, b = (42, console[a = b = void 0] = a++);
|
||||||
|
while (console.log("PASS"));
|
||||||
|
} while (!console);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user