@@ -13049,17 +13049,30 @@ Compressor.prototype.compress = function(node) {
|
||||
|
||||
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;
|
||||
};
|
||||
var def = name.definition();
|
||||
if (def.fixed) {
|
||||
sym.fixed = function() {
|
||||
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 ];
|
||||
}
|
||||
});
|
||||
}
|
||||
def.assignments++;
|
||||
def.references.push(sym);
|
||||
return assign;
|
||||
}
|
||||
|
||||
|
||||
@@ -8151,3 +8151,59 @@ issue_5328: {
|
||||
}
|
||||
expect_stdout: ""
|
||||
}
|
||||
|
||||
issue_5332_1: {
|
||||
options = {
|
||||
inline: true,
|
||||
merge_vars: true,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
do {
|
||||
var a = {};
|
||||
for (A in a)
|
||||
a;
|
||||
} while (function() {
|
||||
console.log(b);
|
||||
var b = b;
|
||||
}());
|
||||
}
|
||||
expect: {
|
||||
do {
|
||||
var a = {};
|
||||
for (A in a);
|
||||
} while (a = void 0, void console.log(a));
|
||||
}
|
||||
expect_stdout: "undefined"
|
||||
}
|
||||
|
||||
issue_5332_2: {
|
||||
options = {
|
||||
inline: true,
|
||||
merge_vars: true,
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
do {
|
||||
var a = 42 in [];
|
||||
for (A in a)
|
||||
a;
|
||||
} while (function() {
|
||||
console.log(++b);
|
||||
var b = b;
|
||||
}());
|
||||
}
|
||||
expect: {
|
||||
do {
|
||||
var a = 42 in [];
|
||||
for (A in a);
|
||||
} while (a = void 0, void console.log(++a));
|
||||
}
|
||||
expect_stdout: "NaN"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user