Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow async as identifier name in certain contexts #2936

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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