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 fa91516
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 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 @@ -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<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 fa91516

Please sign in to comment.