diff --git a/boa_engine/src/syntax/lexer/tests.rs b/boa_engine/src/syntax/lexer/tests.rs index 2553f25c2b5..9c975fe23cc 100644 --- a/boa_engine/src/syntax/lexer/tests.rs +++ b/boa_engine/src/syntax/lexer/tests.rs @@ -634,6 +634,25 @@ fn regex_literal() { expect_tokens(&mut lexer, &expected, &mut interner); } +#[test] +fn regex_equals_following_assignment() { + let mut lexer = Lexer::new(&b"const myRegex = /=/;"[..]); + let mut interner = Interner::default(); + + let expected = [ + TokenKind::Keyword((Keyword::Const, false)), + TokenKind::identifier(interner.get_or_intern_static("myRegex")), + TokenKind::Punctuator(Punctuator::Assign), + TokenKind::regular_expression_literal( + interner.get_or_intern_static("="), + Sym::EMPTY_STRING, + ), + TokenKind::Punctuator(Punctuator::Semicolon), + ]; + + expect_tokens(&mut lexer, &expected, &mut interner); +} + #[test] fn regex_literal_flags() { let mut lexer = Lexer::new(&br"/\/[^\/]*\/*/gmi"[..]); diff --git a/boa_engine/src/syntax/parser/expression/assignment/mod.rs b/boa_engine/src/syntax/parser/expression/assignment/mod.rs index 46bde867c76..414ece80540 100644 --- a/boa_engine/src/syntax/parser/expression/assignment/mod.rs +++ b/boa_engine/src/syntax/parser/expression/assignment/mod.rs @@ -90,7 +90,6 @@ where fn parse(mut self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { let _timer = Profiler::global().start_event("AssignmentExpression", "Parsing"); - cursor.set_goal(InputElement::Div); match cursor .peek(0, interner)? diff --git a/boa_engine/src/syntax/parser/tests.rs b/boa_engine/src/syntax/parser/tests.rs index 5ccc45a0cf5..cfbc9788a6c 100644 --- a/boa_engine/src/syntax/parser/tests.rs +++ b/boa_engine/src/syntax/parser/tests.rs @@ -15,7 +15,7 @@ use crate::{ }, Context, }; -use boa_interner::Interner; +use boa_interner::{Interner, Sym}; /// Checks that the given JavaScript string gives the expected expression. #[allow(clippy::unwrap_used)] @@ -78,6 +78,29 @@ fn assign_operator_precedence() { ); } +#[test] +fn assign_regex_equals() { + let mut interner = Interner::default(); + check_parser( + "let myRegex = /=/;", + vec![DeclarationList::Let( + vec![Declaration::new_with_identifier( + interner.get_or_intern_static("myRegex"), + Node::from(New::from(Call::new( + Identifier::new(Sym::REGEXP), + vec![ + Node::from(Const::from(interner.get_or_intern_static("="))), + Node::from(Const::from(Sym::EMPTY_STRING)), + ], + ))), + )] + .into(), + ) + .into()], + interner, + ); +} + #[test] fn hoisting() { let mut interner = Interner::default();