diff --git a/crates/oxc_parser/src/js/binding.rs b/crates/oxc_parser/src/js/binding.rs index 715ef20f9c66c0..3a1865e51112ce 100644 --- a/crates/oxc_parser/src/js/binding.rs +++ b/crates/oxc_parser/src/js/binding.rs @@ -3,7 +3,7 @@ use oxc_ast::{ast::*, Span}; use oxc_diagnostics::Result; use super::list::{ArrayPatternList, ObjectPatternProperties}; -use crate::{diagnostics, lexer::Kind, list::SeparatedList, Parser}; +use crate::{diagnostics, lexer::Kind, list::SeparatedList, Context, Parser}; impl<'a> Parser<'a> { /// Destructuring Binding Patterns @@ -64,17 +64,17 @@ impl<'a> Parser<'a> { Ok(self.ast.rest_element(span, argument)) } - /// `BindingElement` - /// `SingleNameBinding` - /// `BindingPattern` Initializer + /// BindingElement + /// SingleNameBinding + /// BindingPattern[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt pub(crate) fn parse_binding_element(&mut self) -> Result> { let span = self.start_span(); let pattern = self.parse_binding_pattern()?.0; - self.parse_initializer(span, pattern) + self.with_context(Context::In, |p| p.parse_initializer(span, pattern)) } // object pattern property only has kind: init and method: false - // Result> { let span = self.start_span(); diff --git a/crates/oxc_parser/src/lib.rs b/crates/oxc_parser/src/lib.rs index 71f3c94aa9e35c..2e0d8303783ae0 100644 --- a/crates/oxc_parser/src/lib.rs +++ b/crates/oxc_parser/src/lib.rs @@ -292,6 +292,7 @@ mod test { "switch(null){case async():}", "for(new null(null in null);;);", "for(`${null in null}`;;);", + "for(var[l=null in null]in null);", ]; for source in pass {