fix corner case
add test
This commit is contained in:
parent
ab09e869f9
commit
4999af294a
|
|
@ -1677,10 +1677,9 @@ merge(Compressor.prototype, {
|
|||
} else if (stat instanceof AST_For) {
|
||||
if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
|
||||
if (stat.init) {
|
||||
stat.init.definitions = prev.definitions.concat(stat.init.definitions);
|
||||
} else {
|
||||
stat.init = prev;
|
||||
prev.definitions = prev.definitions.concat(stat.init.definitions);
|
||||
}
|
||||
stat.init = prev;
|
||||
statements[j] = stat;
|
||||
CHANGED = true;
|
||||
} else if (defs && stat.init && defs.TYPE == stat.init.TYPE && declarations_only(stat.init)) {
|
||||
|
|
|
|||
|
|
@ -833,3 +833,29 @@ hoist_decl: {
|
|||
for (y(); 0;) z();
|
||||
}
|
||||
}
|
||||
|
||||
for_init_var: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
unused: false,
|
||||
}
|
||||
input: {
|
||||
var a = "PASS";
|
||||
(function() {
|
||||
var b = 42;
|
||||
for (var c = 5; c > 0;) c--;
|
||||
a = "FAIL";
|
||||
var a;
|
||||
})();
|
||||
console.log(a);
|
||||
}
|
||||
expect: {
|
||||
var a = "PASS";
|
||||
(function() {
|
||||
for (var b = 42, c = 5, a; c > 0;) c--;
|
||||
a = "FAIL";
|
||||
})();
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user