enhance merge_vars (#4152)
This commit is contained in:
@@ -4538,9 +4538,7 @@ merge(Compressor.prototype, {
|
||||
if (def.id in references) {
|
||||
var refs = references[def.id];
|
||||
if (!refs) return;
|
||||
if (write ? refs.start !== segment : refs.start.block !== segment.block) {
|
||||
return references[def.id] = false;
|
||||
}
|
||||
if (refs.start.block !== segment.block) return references[def.id] = false;
|
||||
refs.push(sym);
|
||||
refs.end = segment;
|
||||
if (def.id in prev) {
|
||||
|
||||
@@ -2800,3 +2800,25 @@ lambda_reuse: {
|
||||
"string",
|
||||
]
|
||||
}
|
||||
|
||||
conditional_write: {
|
||||
options = {
|
||||
merge_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var a = "FAIL", b;
|
||||
if (console)
|
||||
a = "PASS";
|
||||
b = [a, 42].join();
|
||||
console.log(b);
|
||||
}
|
||||
expect: {
|
||||
var b = "FAIL", b;
|
||||
if (console)
|
||||
b = "PASS";
|
||||
b = [b, 42].join();
|
||||
console.log(b);
|
||||
}
|
||||
expect_stdout: "PASS,42"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user