@@ -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
+ uint8_t has_iterator : 1;
18630
+ uint8_t 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) {
@@ -25335,7 +25338,8 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name,
25335
25338
JS_FreeAtom(ctx, var_name);
25336
25339
25337
25340
if (token_is_pseudo_keyword(s, JS_ATOM_of)) {
25338
- break_entry.has_iterator = is_for_of = TRUE;
25341
+ is_for_of = TRUE;
25342
+ break_entry.has_iterator = TRUE;
25339
25343
break_entry.drop_count += 2;
25340
25344
if (has_initializer)
25341
25345
goto initializer_error;
@@ -25479,13 +25483,14 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
25479
25483
&& s->token.val != TOK_DO
25480
25484
&& s->token.val != TOK_WHILE) {
25481
25485
/* labelled regular statement */
25486
+ JSFunctionDef *fd = s->cur_func;
25482
25487
int label_break, mask;
25483
25488
BlockEnv break_entry;
25484
25489
25485
25490
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 &&
25491
+ push_break_entry(fd , &break_entry, label_name, label_break, -1, 0);
25492
+ fd->top_break->is_regular_stmt = 1 ;
25493
+ if (!fd ->is_strict_mode &&
25489
25494
(decl_mask & DECL_MASK_FUNC_WITH_LABEL)) {
25490
25495
mask = DECL_MASK_FUNC | DECL_MASK_FUNC_WITH_LABEL;
25491
25496
} else {
@@ -25494,7 +25499,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
25494
25499
if (js_parse_statement_or_decl(s, mask))
25495
25500
goto fail;
25496
25501
emit_label(s, label_break);
25497
- pop_break_entry(s->cur_func );
25502
+ pop_break_entry(fd );
25498
25503
goto done;
25499
25504
}
25500
25505
}
0 commit comments