@@ -3315,7 +3315,21 @@ merge(Compressor.prototype, {
|
||||
});
|
||||
|
||||
AST_Definitions.DEFMETHOD("remove_initializers", function(){
|
||||
this.definitions.forEach(function(def){ def.value = null });
|
||||
var decls = [];
|
||||
this.definitions.forEach(function(def) {
|
||||
if (def.name instanceof AST_SymbolDeclaration) {
|
||||
def.value = null;
|
||||
decls.push(def);
|
||||
} else def.name.walk(new TreeWalker(function(node) {
|
||||
if (node instanceof AST_SymbolDeclaration) {
|
||||
decls.push(make_node(AST_VarDef, def, {
|
||||
name: node,
|
||||
value: null
|
||||
}));
|
||||
}
|
||||
}));
|
||||
});
|
||||
this.definitions = decls;
|
||||
});
|
||||
|
||||
AST_Definitions.DEFMETHOD("to_assignments", function(compressor){
|
||||
|
||||
@@ -560,3 +560,64 @@ global_fns: {
|
||||
"RangeError",
|
||||
]
|
||||
}
|
||||
|
||||
issue_2383_1: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
}
|
||||
input: {
|
||||
if (0) {
|
||||
var {x, y} = foo();
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
var x, y;
|
||||
}
|
||||
}
|
||||
|
||||
issue_2383_2: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
}
|
||||
input: {
|
||||
if (0) {
|
||||
var {
|
||||
x = 0,
|
||||
y: [ w, , { z, p: q = 7 } ] = [ 1, 2, { z: 3 } ]
|
||||
} = {};
|
||||
}
|
||||
console.log(x, q, w, z);
|
||||
}
|
||||
expect: {
|
||||
var x, w, z, q;
|
||||
console.log(x, q, w, z);
|
||||
}
|
||||
expect_stdout: "undefined undefined undefined undefined"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_2383_3: {
|
||||
options = {
|
||||
conditionals: true,
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
}
|
||||
input: {
|
||||
var b = 7, y = 8;
|
||||
if (0) {
|
||||
var a = 1, [ x, y, z ] = [ 2, 3, 4 ], b = 5;
|
||||
}
|
||||
console.log(a, x, y, z, b);
|
||||
}
|
||||
expect: {
|
||||
var b = 7, y = 8;
|
||||
var a, x, y, z, b;
|
||||
console.log(a, x, y, z, b);
|
||||
}
|
||||
expect_stdout: "undefined undefined 8 undefined 7"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user