@@ -18626,7 +18626,8 @@ typedef struct BlockEnv {
18626
18626
int drop_count; /* number of stack elements to drop */
18627
18627
int label_finally; /* -1 if none */
18628
18628
int scope_level;
18629
- int has_iterator;
18629
+ BOOL has_iterator : 1;
18630
+ BOOL is_regular_stmt : 1; // i.e. not a loop statement
18630
18631
} BlockEnv;
18631
18632
18632
18633
typedef struct JSGlobalVar {
@@ -24891,6 +24892,7 @@ static void push_break_entry(JSFunctionDef *fd, BlockEnv *be,
24891
24892
be->label_finally = -1;
24892
24893
be->scope_level = fd->scope_level;
24893
24894
be->has_iterator = FALSE;
24895
+ be->is_regular_stmt = FALSE;
24894
24896
}
24895
24897
24896
24898
static void pop_break_entry(JSFunctionDef *fd)
@@ -24917,11 +24919,12 @@ static __exception int emit_break(JSParseState *s, JSAtom name, int is_cont)
24917
24919
emit_goto(s, OP_goto, top->label_cont);
24918
24920
return 0;
24919
24921
}
24920
- if (!is_cont &&
24921
- top->label_break != -1 &&
24922
- (name == JS_ATOM_NULL || top->label_name == name)) {
24923
- emit_goto(s, OP_goto, top->label_break);
24924
- return 0;
24922
+ if (!is_cont && top->label_break != -1) {
24923
+ if (top->label_name == name ||
24924
+ (name == JS_ATOM_NULL && !top->is_regular_stmt)) {
24925
+ emit_goto(s, OP_goto, top->label_break);
24926
+ return 0;
24927
+ }
24925
24928
}
24926
24929
i = 0;
24927
24930
if (top->has_iterator) {
@@ -25479,13 +25482,14 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
25479
25482
&& s->token.val != TOK_DO
25480
25483
&& s->token.val != TOK_WHILE) {
25481
25484
/* labelled regular statement */
25485
+ JSFunctionDef *fd = s->cur_func;
25482
25486
int label_break, mask;
25483
25487
BlockEnv break_entry;
25484
25488
25485
25489
label_break = new_label(s);
25486
- push_break_entry(s->cur_func , &break_entry,
25487
- label_name, label_break, -1, 0) ;
25488
- if (!s->cur_func ->is_strict_mode &&
25490
+ push_break_entry(fd , &break_entry, label_name, label_break, -1, 0);
25491
+ fd->top_break->is_regular_stmt = 1 ;
25492
+ if (!fd ->is_strict_mode &&
25489
25493
(decl_mask & DECL_MASK_FUNC_WITH_LABEL)) {
25490
25494
mask = DECL_MASK_FUNC | DECL_MASK_FUNC_WITH_LABEL;
25491
25495
} else {
@@ -25494,7 +25498,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
25494
25498
if (js_parse_statement_or_decl(s, mask))
25495
25499
goto fail;
25496
25500
emit_label(s, label_break);
25497
- pop_break_entry(s->cur_func );
25501
+ pop_break_entry(fd );
25498
25502
goto done;
25499
25503
}
25500
25504
}
0 commit comments