@@ -763,6 +763,22 @@ Compressor.prototype.compress = function(node) {
|
||||
};
|
||||
}
|
||||
|
||||
function make_fixed_default(compressor, node, save) {
|
||||
var prev_save, prev_seq;
|
||||
return function() {
|
||||
var current = save();
|
||||
var ev;
|
||||
if (!is_undefined(current, compressor) && (ev = fuzzy_eval(compressor, current, true)) !== undefined) {
|
||||
return ev instanceof AST_Node ? node : current;
|
||||
}
|
||||
if (prev_save !== current) {
|
||||
prev_save = current;
|
||||
prev_seq = make_sequence(node, [ current, node.value ]);
|
||||
}
|
||||
return prev_seq;
|
||||
};
|
||||
}
|
||||
|
||||
function scan_declaration(tw, compressor, lhs, fixed, visit) {
|
||||
var scanner = new TreeWalker(function(node) {
|
||||
if (node instanceof AST_DefaultValue) {
|
||||
@@ -771,14 +787,7 @@ Compressor.prototype.compress = function(node) {
|
||||
node.value.walk(tw);
|
||||
pop(tw);
|
||||
var save = fixed;
|
||||
if (save) fixed = make_fixed(save, function(value) {
|
||||
var ev;
|
||||
if (is_undefined(value, compressor)
|
||||
|| (ev = fuzzy_eval(compressor, value, true)) === undefined) {
|
||||
return make_sequence(node, [ value, node.value ]);
|
||||
}
|
||||
return ev instanceof AST_Node ? node : value;
|
||||
});
|
||||
if (save) fixed = make_fixed_default(compressor, node, save);
|
||||
node.name.walk(scanner);
|
||||
fixed = save;
|
||||
return true;
|
||||
|
||||
@@ -2209,3 +2209,33 @@ issue_5340_3: {
|
||||
expect_stdout: "undefined"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5407: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
(function(a) {
|
||||
for (var i = 0; i < 2; i++)
|
||||
(function(b = 4) {
|
||||
console.log(b);
|
||||
a = 2;
|
||||
})(a);
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
(function(a) {
|
||||
for (var i = 0; i < 2; i++)
|
||||
(function(b = 4) {
|
||||
console.log(b);
|
||||
a = 2;
|
||||
})(a);
|
||||
})();
|
||||
}
|
||||
expect_stdout: [
|
||||
"4",
|
||||
"2",
|
||||
]
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user