Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix(rome_js_parser): async label #3612
Browse files Browse the repository at this point in the history
  • Loading branch information
denbezrukov committed Nov 21, 2022
1 parent 861eb07 commit e512dbe
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/rome_js_parser/src/syntax/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
async: for(a of b) continue async;
55 changes: 55 additions & 0 deletions crates/rome_js_parser/test_data/inline/ok/async_continue_stmt.rast
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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")] []

0 comments on commit e512dbe

Please sign in to comment.