Browse Source

Allow escaped `let` as expression (#2916)

pull/2918/head
Haled Odat 2 years ago committed by GitHub
parent
commit
d7c03db7fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      boa_parser/src/parser/statement/expression/mod.rs
  2. 7
      boa_parser/src/parser/statement/mod.rs

5
boa_parser/src/parser/statement/expression/mod.rs

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

7
boa_parser/src/parser/statement/mod.rs

@ -416,10 +416,9 @@ where
let tok = cursor.peek(0, interner).or_abrupt()?;
match *tok.kind() {
TokenKind::Keyword((
Keyword::Function | Keyword::Class | Keyword::Const | Keyword::Let,
_,
)) => Declaration::new(self.allow_yield, self.allow_await)
TokenKind::Keyword(
(Keyword::Function | Keyword::Class | Keyword::Const, _) | (Keyword::Let, false),
) => Declaration::new(self.allow_yield, self.allow_await)
.parse(cursor, interner)
.map(ast::StatementListItem::from),
TokenKind::Keyword((Keyword::Async, _)) => {

Loading…
Cancel
Save