Skip to content

Commit

Permalink
Fix for-of expression parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Apr 29, 2023
1 parent 04ddeeb commit a42fa02
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions boa_parser/src/parser/statement/iteration/for_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use crate::{
lexer::{Error as LexError, TokenKind},
parser::{
expression::Expression,
expression::{AssignmentExpression, Expression},
statement::declaration::LexicalDeclaration,
statement::{variable::VariableDeclarationList, Statement},
AllowAwait, AllowReturn, AllowYield, Cursor, OrAbrupt, ParseResult, TokenParser,
Expand Down Expand Up @@ -169,8 +169,13 @@ where
)?;

cursor.advance(interner);
let expr = Expression::new(None, true, self.allow_yield, self.allow_await)
.parse(cursor, interner)?;
let expr = if in_loop {
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)?;

Expand Down

0 comments on commit a42fa02

Please sign in to comment.