Skip to content

Commit

Permalink
fix(parser): fix [+In] Destructuring Binding Pattern Initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Apr 6, 2023
1 parent 398dbfd commit 8f2efea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/oxc_parser/src/js/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,15 +66,15 @@ impl<'a> Parser<'a> {

/// `BindingElement`
/// `SingleNameBinding`
/// `BindingPattern` Initializer
/// `BindingPattern`[?Yield, ?Await] `Initializer`[+In, ?Yield, ?Await]opt
pub(crate) fn parse_binding_element(&mut self) -> Result<BindingPattern<'a>> {
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
// <https://github.com/oxc_ast/oxc_ast/blob/master/es2015.md#objectpattern
// <https://github.com/estree/estree/blob/master/es2015.md#objectpattern
pub(crate) fn parse_object_pattern_property(&mut self) -> Result<Property<'a>> {
let span = self.start_span();

Expand Down
1 change: 1 addition & 0 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8f2efea

Please sign in to comment.