enhance join_vars (#4089)
This commit is contained in:
@@ -2644,6 +2644,14 @@ merge(Compressor.prototype, {
|
|||||||
defs = stat.init;
|
defs = stat.init;
|
||||||
}
|
}
|
||||||
} else if (stat instanceof AST_ForIn) {
|
} else if (stat instanceof AST_ForIn) {
|
||||||
|
if (defs && defs.TYPE == stat.init.TYPE) {
|
||||||
|
defs.definitions = defs.definitions.concat(stat.init.definitions);
|
||||||
|
var name = stat.init.definitions[0].name;
|
||||||
|
var ref = make_node(AST_SymbolRef, name, name);
|
||||||
|
name.definition().references.push(ref);
|
||||||
|
stat.init = ref;
|
||||||
|
CHANGED = true;
|
||||||
|
}
|
||||||
stat.object = join_assigns_expr(stat.object);
|
stat.object = join_assigns_expr(stat.object);
|
||||||
} else if (stat instanceof AST_If) {
|
} else if (stat instanceof AST_If) {
|
||||||
stat.condition = join_assigns_expr(stat.condition);
|
stat.condition = join_assigns_expr(stat.condition);
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ join_object_assignments_forin: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(function() {
|
console.log(function() {
|
||||||
var o = { a: "PASS" };
|
var o = { a: "PASS" }, a;
|
||||||
for (var a in o)
|
for (a in o)
|
||||||
return o[a];
|
return o[a];
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
var o = this;
|
UNUSED: {
|
||||||
|
console.log(0 - .1 - .1 - .1);
|
||||||
for (var k in o) L17060: {
|
|
||||||
a++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var a;
|
|
||||||
|
|
||||||
console.log(k);
|
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
// (beautified)
|
// (beautified)
|
||||||
var o = this;
|
console.log(0 - 1 - .1 - .1);
|
||||||
|
// output: -1.2000000000000002
|
||||||
for (var k in o) {}
|
|
||||||
|
|
||||||
var a;
|
|
||||||
|
|
||||||
console.log(k);
|
|
||||||
// output: a
|
|
||||||
//
|
//
|
||||||
// minify: k
|
// minify: -1.2
|
||||||
//
|
//
|
||||||
// options: {
|
// options: {
|
||||||
|
// "compress": {
|
||||||
|
// "unsafe_math": true
|
||||||
|
// },
|
||||||
// "mangle": false
|
// "mangle": false
|
||||||
// }
|
// }
|
||||||
@@ -24,6 +24,9 @@ describe("test/reduce.js", function() {
|
|||||||
});
|
});
|
||||||
it("Should eliminate unreferenced labels", function() {
|
it("Should eliminate unreferenced labels", function() {
|
||||||
var result = reduce_test(read("test/input/reduce/label.js"), {
|
var result = reduce_test(read("test/input/reduce/label.js"), {
|
||||||
|
compress: {
|
||||||
|
unsafe_math: true,
|
||||||
|
},
|
||||||
mangle: false,
|
mangle: false,
|
||||||
}, {
|
}, {
|
||||||
verbose: false,
|
verbose: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user