Browse Source

Fix `for-of` expression parsing (#2882)

This PR makes parsing of expressions in for-of loops use `AssignmentExpression` expression parsing as defined in the spec.
pull/2888/head
Haled Odat 2 years ago
parent
commit
dff815d545
  1. 11
      boa_parser/src/parser/statement/iteration/for_statement.rs

11
boa_parser/src/parser/statement/iteration/for_statement.rs

@ -10,7 +10,7 @@
use crate::{ use crate::{
lexer::{Error as LexError, TokenKind}, lexer::{Error as LexError, TokenKind},
parser::{ parser::{
expression::Expression, expression::{AssignmentExpression, Expression},
statement::declaration::LexicalDeclaration, statement::declaration::LexicalDeclaration,
statement::{variable::VariableDeclarationList, Statement}, statement::{variable::VariableDeclarationList, Statement},
AllowAwait, AllowReturn, AllowYield, Cursor, OrAbrupt, ParseResult, TokenParser, AllowAwait, AllowReturn, AllowYield, Cursor, OrAbrupt, ParseResult, TokenParser,
@ -169,8 +169,13 @@ where
)?; )?;
cursor.advance(interner); cursor.advance(interner);
let expr = Expression::new(None, true, self.allow_yield, self.allow_await) let expr = if in_loop {
.parse(cursor, interner)?; Expression::new(None, true, self.allow_yield, self.allow_await)
.parse(cursor, interner)?
} else {
AssignmentExpression::new(None, true, self.allow_yield, self.allow_await)
.parse(cursor, interner)?
};
cursor.expect(Punctuator::CloseParen, "for in/of statement", interner)?; cursor.expect(Punctuator::CloseParen, "for in/of statement", interner)?;

Loading…
Cancel
Save