Skip to content

Commit

Permalink
Allow escaped async as binding name (#2936)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 authored May 17, 2023
1 parent 190eeb3 commit 4f25f2c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion boa_parser/src/parser/expression/assignment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ where
}
}
// AsyncArrowFunction[?In, ?Yield, ?Await]
TokenKind::Keyword((Keyword::Async, _)) => {
TokenKind::Keyword((Keyword::Async, false)) => {
let skip_n = if cursor.peek_is_line_terminator(0, interner).or_abrupt()? {
2
} else {
Expand Down
8 changes: 1 addition & 7 deletions boa_parser/src/parser/expression/primary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,8 @@ where

match cursor.peek(1, interner)?.map(Token::kind) {
Some(TokenKind::Keyword((Keyword::Function, _)))
if !is_line_terminator && contain_escaped_char =>
if !is_line_terminator && !contain_escaped_char =>
{
Err(Error::general(
"Keyword must not contain escaped characters",
tok_position,
))
}
Some(TokenKind::Keyword((Keyword::Function, _))) if !is_line_terminator => {
cursor.advance(interner);
match cursor.peek(1, interner)?.map(Token::kind) {
Some(TokenKind::Punctuator(Punctuator::Mul)) => {
Expand Down
6 changes: 2 additions & 4 deletions boa_parser/src/parser/statement/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where

let next_token = cursor.peek(0, interner).or_abrupt()?;
match next_token.kind() {
TokenKind::Keyword((Keyword::Function | Keyword::Class | Keyword::Async, true)) => {
TokenKind::Keyword((Keyword::Function | Keyword::Class, true)) => {
return Err(Error::general(
"Keyword must not contain escaped characters",
next_token.span().start(),
Expand All @@ -69,9 +69,7 @@ where
.peek_is_line_terminator(skip_n, interner)?
.unwrap_or(true);

if is_line_terminator {
{}
} else {
if !is_line_terminator {
let next_token = cursor.peek(1, interner).or_abrupt()?;
match next_token.kind() {
TokenKind::Keyword((Keyword::Function, true)) => {
Expand Down
2 changes: 1 addition & 1 deletion boa_parser/src/parser/statement/iteration/for_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ where
.parse(cursor, interner)?
.into(),
),
TokenKind::Keyword((Keyword::Async, false)) => {
TokenKind::Keyword((Keyword::Async, false)) if !r#await => {
match cursor.peek(1, interner).or_abrupt()?.kind() {
TokenKind::Keyword((Keyword::Of, _)) => {
return Err(Error::lex(LexError::Syntax(
Expand Down
2 changes: 1 addition & 1 deletion boa_parser/src/parser/statement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ where
) => Declaration::new(self.allow_yield, self.allow_await)
.parse(cursor, interner)
.map(ast::StatementListItem::from),
TokenKind::Keyword((Keyword::Async, _)) => {
TokenKind::Keyword((Keyword::Async, false)) => {
let skip_n = if cursor.peek_is_line_terminator(0, interner).or_abrupt()? {
2
} else {
Expand Down

0 comments on commit 4f25f2c

Please sign in to comment.