fix corner case in merge_vars (#4635)
This commit is contained in:
@@ -5045,6 +5045,7 @@ merge(Compressor.prototype, {
|
|||||||
return self;
|
return self;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var NO_MERGE = makePredicate("arguments await yield");
|
||||||
AST_Scope.DEFMETHOD("merge_variables", function(compressor) {
|
AST_Scope.DEFMETHOD("merge_variables", function(compressor) {
|
||||||
if (!compressor.option("merge_vars")) return;
|
if (!compressor.option("merge_vars")) return;
|
||||||
var self = this, segment = {}, root;
|
var self = this, segment = {}, root;
|
||||||
@@ -5386,7 +5387,7 @@ merge(Compressor.prototype, {
|
|||||||
} else if ((ldef = self.variables.get(def.name)) !== def) {
|
} else if ((ldef = self.variables.get(def.name)) !== def) {
|
||||||
if (ldef && root === segment) references[ldef.id] = false;
|
if (ldef && root === segment) references[ldef.id] = false;
|
||||||
return references[def.id] = false;
|
return references[def.id] = false;
|
||||||
} else if (compressor.exposed(def) || sym.name == "arguments" || sym.name == "await") {
|
} else if (compressor.exposed(def) || NO_MERGE[sym.name]) {
|
||||||
return references[def.id] = false;
|
return references[def.id] = false;
|
||||||
} else {
|
} else {
|
||||||
var refs = declarations.get(def.id) || [];
|
var refs = declarations.get(def.id) || [];
|
||||||
|
|||||||
@@ -602,6 +602,62 @@ inline_nested_yield: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4454_1: {
|
||||||
|
rename = false
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
(function*(b = console.log(a)) {})();
|
||||||
|
var yield = 42..toString();
|
||||||
|
console.log(yield);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
(function*(b = console.log(a)) {})();
|
||||||
|
var yield = 42..toString();
|
||||||
|
console.log(yield);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"42",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4454_2: {
|
||||||
|
rename = true
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
(function*(b = console.log(a)) {})();
|
||||||
|
var yield = 42..toString();
|
||||||
|
console.log(yield);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(b) {
|
||||||
|
(function*(c = console.log(b)) {})();
|
||||||
|
var b = 42..toString();
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"42",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4618: {
|
issue_4618: {
|
||||||
options = {
|
options = {
|
||||||
functions: true,
|
functions: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user