Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): fix [+In] Destructuring Binding Pattern Initializer #267

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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