fix(rome_js_parser): async label
Fix
MODIFY
crates/rome_js_parser/src/syntax/stmt.rs
crates/rome_js_parser/src/syntax/stmt.rs
@@ -585,7 +585,9 @@ fn parse_continue_statement(p: &mut Parser) -> ParsedSyntax {
let start = p.cur_range();
p.expect(T![continue]); // continue keyword
- let error = if !p.has_preceding_line_break() && p.at(T![ident]) {
+ // test async_continue_stmt
+ // async: for(a of b) continue async;
+ let error = if !p.has_preceding_line_break() && is_at_identifier(p) {
let label_name = p.cur_src();
let error = match p.state.get_labelled_item(label_name) {
@@ -608,7 +610,7 @@ fn parse_continue_statement(p: &mut Parser) -> ParsedSyntax {
}
};
- p.bump_any();
+ p.bump_remap(T![ident]);
error
} else if !p.state.continue_allowed() {

ADD
crates/rome_js_parser/test_data/inline/ok/async_continue_stmt.js
+async: for(a of b) continue async;

ADD
crates/rome_js_parser/test_data/inline/ok/async_continue_stmt.rast
+JsModule {
+ interpreter_token: missing (optional),
+ directives: JsDirectiveList [],
+ items: JsModuleItemList [
+ JsLabeledStatement {
+ label_token: IDENT@0..5 "async" [] [],
+ colon_token: COLON@5..7 ":" [] [Whitespace(" ")],
+ body: JsForOfStatement {
+ for_token: FOR_KW@7..10 "for" [] [],
+ await_token: missing (optional),
+ l_paren_token: L_PAREN@10..11 "(" [] [],
+ initializer: JsIdentifierAssignment {
+ name_token: IDENT@11..13 "a" [] [Whitespace(" ")],
+ },
+ of_token: OF_KW@13..16 "of" [] [Whitespace(" ")],
+ expression: JsIdentifierExpression {
+ name: JsReferenceIdentifier {
+ value_token: IDENT@16..17 "b" [] [],
+ },
+ },
+ r_paren_token: R_PAREN@17..19 ")" [] [Whitespace(" ")],
+ body: JsContinueStatement {
+ continue_token: CONTINUE_KW@19..28 "continue" [] [Whitespace(" ")],
+ label_token: IDENT@28..33 "async" [] [],
+ semicolon_token: SEMICOLON@33..34 ";" [] [],
+ },
+ },
+ },
+ ],
+ eof_token: EOF@34..35 "" [Newline("\n")] [],
+}
+
+0: JS_MODULE@0..35
+ 0: (empty)
+ 1: JS_DIRECTIVE_LIST@0..0
+ 2: JS_MODULE_ITEM_LIST@0..34
+ 0: JS_LABELED_STATEMENT@0..34
+ 0: IDENT@0..5 "async" [] []
+ 1: COLON@5..7 ":" [] [Whitespace(" ")]
+ 2: JS_FOR_OF_STATEMENT@7..34
+ 0: FOR_KW@7..10 "for" [] []
+ 1: (empty)
+ 2: L_PAREN@10..11 "(" [] []
+ 3: JS_IDENTIFIER_ASSIGNMENT@11..13
+ 0: IDENT@11..13 "a" [] [Whitespace(" ")]
+ 4: OF_KW@13..16 "of" [] [Whitespace(" ")]
+ 5: JS_IDENTIFIER_EXPRESSION@16..17
+ 0: JS_REFERENCE_IDENTIFIER@16..17
+ 0: IDENT@16..17 "b" [] []
+ 6: R_PAREN@17..19 ")" [] [Whitespace(" ")]
+ 7: JS_CONTINUE_STATEMENT@19..34
+ 0: CONTINUE_KW@19..28 "continue" [] [Whitespace(" ")]
+ 1: IDENT@28..33 "async" [] []
+ 2: SEMICOLON@33..34 ";" [] []
+ 3: EOF@34..35 "" [Newline("\n")] []

fix(rome_js_parser): async label #3612 (#3808)

Fix https://github.com/rome/tools/issues/3612