fix empty statement with label
This commit is contained in:
parent
9195a5b56d
commit
a7e607d34e
|
|
@ -2395,7 +2395,7 @@ merge(Compressor.prototype, {
|
|||
if (compressor.option("dead_code") && self instanceof AST_While) {
|
||||
var a = [];
|
||||
extract_declarations_from_unreachable_code(compressor, self.body, a);
|
||||
return make_node(AST_BlockStatement, self, { body: a });
|
||||
return make_node(AST_BlockStatement, self, { body: a }).optimize(compressor);
|
||||
}
|
||||
if (self instanceof AST_Do) {
|
||||
var has_loop_control = false;
|
||||
|
|
@ -2475,7 +2475,7 @@ merge(Compressor.prototype, {
|
|||
}));
|
||||
}
|
||||
extract_declarations_from_unreachable_code(compressor, self.body, a);
|
||||
return make_node(AST_BlockStatement, self, { body: a });
|
||||
return make_node(AST_BlockStatement, self, { body: a }).optimize(compressor);
|
||||
}
|
||||
if (cond !== self.condition) {
|
||||
cond = make_node_from_constant(cond, self.condition).transform(compressor);
|
||||
|
|
@ -2727,9 +2727,9 @@ merge(Compressor.prototype, {
|
|||
var body = [];
|
||||
if (self.bcatch) extract_declarations_from_unreachable_code(compressor, self.bcatch, body);
|
||||
if (self.bfinally) body = body.concat(self.bfinally.body);
|
||||
return body.length > 0 ? make_node(AST_BlockStatement, self, {
|
||||
return make_node(AST_BlockStatement, self, {
|
||||
body: body
|
||||
}).optimize(compressor) : make_node(AST_EmptyStatement, self);
|
||||
}).optimize(compressor);
|
||||
}
|
||||
return self;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -190,11 +190,7 @@ function OutputStream(options) {
|
|||
var might_need_space = false;
|
||||
var might_need_semicolon = false;
|
||||
var might_add_newline = 0;
|
||||
var last = null;
|
||||
|
||||
function last_char() {
|
||||
return last.charAt(last.length - 1);
|
||||
};
|
||||
var last = "";
|
||||
|
||||
var ensure_line_len = options.max_line_len ? function() {
|
||||
if (current_col > options.max_line_len) {
|
||||
|
|
@ -218,10 +214,11 @@ function OutputStream(options) {
|
|||
function print(str) {
|
||||
str = String(str);
|
||||
var ch = str.charAt(0);
|
||||
var prev = last.charAt(last.length - 1);
|
||||
if (might_need_semicolon) {
|
||||
might_need_semicolon = false;
|
||||
|
||||
if ((!ch || ";}".indexOf(ch) < 0) && !/[;]$/.test(last)) {
|
||||
if (prev == ":" && ch == "}" || (!ch || ";}".indexOf(ch) < 0) && prev != ";") {
|
||||
if (options.semicolons || requireSemicolonChars(ch)) {
|
||||
OUTPUT += ";";
|
||||
current_col++;
|
||||
|
|
@ -258,7 +255,6 @@ function OutputStream(options) {
|
|||
}
|
||||
|
||||
if (might_need_space) {
|
||||
var prev = last_char();
|
||||
if ((is_identifier_char(prev)
|
||||
&& (is_identifier_char(ch) || ch == "\\"))
|
||||
|| (ch == "/" && ch == prev)
|
||||
|
|
|
|||
|
|
@ -118,3 +118,17 @@ label_do: {
|
|||
} while (0);
|
||||
}
|
||||
}
|
||||
|
||||
label_while: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
dead_code: true,
|
||||
loops: true,
|
||||
}
|
||||
input: {
|
||||
function f() {
|
||||
L: while (0) continue L;
|
||||
}
|
||||
}
|
||||
expect_exact: "function f(){L:;}"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user