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 (#3808)
Browse files Browse the repository at this point in the history
Fix #3612
  • Loading branch information
denbezrukov committed Nov 21, 2022
1 parent cb33205 commit 4a90642
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: [email protected] "async" [] [],
colon_token: [email protected] ":" [] [Whitespace(" ")],
body: JsForOfStatement {
for_token: [email protected] "for" [] [],
await_token: missing (optional),
l_paren_token: [email protected] "(" [] [],
initializer: JsIdentifierAssignment {
name_token: [email protected] "a" [] [Whitespace(" ")],
},
of_token: [email protected] "of" [] [Whitespace(" ")],
expression: JsIdentifierExpression {
name: JsReferenceIdentifier {
value_token: [email protected] "b" [] [],
},
},
r_paren_token: [email protected] ")" [] [Whitespace(" ")],
body: JsContinueStatement {
continue_token: [email protected] "continue" [] [Whitespace(" ")],
label_token: [email protected] "async" [] [],
semicolon_token: [email protected] ";" [] [],
},
},
},
],
eof_token: [email protected] "" [Newline("\n")] [],
}

0: [email protected]
0: (empty)
1: [email protected]
2: [email protected]
0: [email protected]
0: [email protected] "async" [] []
1: [email protected] ":" [] [Whitespace(" ")]
2: [email protected]
0: [email protected] "for" [] []
1: (empty)
2: [email protected] "(" [] []
3: [email protected]
0: [email protected] "a" [] [Whitespace(" ")]
4: [email protected] "of" [] [Whitespace(" ")]
5: [email protected]
0: [email protected]
0: [email protected] "b" [] []
6: [email protected] ")" [] [Whitespace(" ")]
7: [email protected]
0: [email protected] "continue" [] [Whitespace(" ")]
1: [email protected] "async" [] []
2: [email protected] ";" [] []
3: [email protected] "" [Newline("\n")] []

0 comments on commit 4a90642

Please sign in to comment.