fix corner case in AST_For.init (#1652)
Enforce `null` as value for empty initialisation blocks. fixes #1648
This commit is contained in:
@@ -2327,6 +2327,7 @@ merge(Compressor.prototype, {
|
|||||||
};
|
};
|
||||||
|
|
||||||
OPT(AST_For, function(self, compressor){
|
OPT(AST_For, function(self, compressor){
|
||||||
|
if (is_empty(self.init)) self.init = null;
|
||||||
if (!compressor.option("loops")) return self;
|
if (!compressor.option("loops")) return self;
|
||||||
if (self.condition) {
|
if (self.condition) {
|
||||||
var cond = self.condition.evaluate(compressor);
|
var cond = self.condition.evaluate(compressor);
|
||||||
|
|||||||
@@ -799,7 +799,7 @@ function OutputStream(options) {
|
|||||||
output.print("for");
|
output.print("for");
|
||||||
output.space();
|
output.space();
|
||||||
output.with_parens(function(){
|
output.with_parens(function(){
|
||||||
if (self.init && !(self.init instanceof AST_EmptyStatement)) {
|
if (self.init) {
|
||||||
if (self.init instanceof AST_Definitions) {
|
if (self.init instanceof AST_Definitions) {
|
||||||
self.init.print(output);
|
self.init.print(output);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -440,3 +440,21 @@ issue_186_beautify_bracketize_ie8: {
|
|||||||
'}',
|
'}',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_1648: {
|
||||||
|
options = {
|
||||||
|
join_vars: true,
|
||||||
|
loops: true,
|
||||||
|
passes: 2,
|
||||||
|
sequences: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
x();
|
||||||
|
var b = 1;
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_exact: "function f(){for(x();1;);}"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user