diff --git a/crates/oxc_parser/src/cursor.rs b/crates/oxc_parser/src/cursor.rs index 45650dda2112..9339200aeaca 100644 --- a/crates/oxc_parser/src/cursor.rs +++ b/crates/oxc_parser/src/cursor.rs @@ -1,8 +1,9 @@ //! Code related to navigating `Token`s from the lexer +use oxc_allocator::Vec; use oxc_ast::ast::{Decorator, RegExpFlags}; use oxc_diagnostics::Result; -use oxc_span::Span; +use oxc_span::{GetSpan, Span}; use crate::{ diagnostics, @@ -330,7 +331,7 @@ impl<'a> ParserImpl<'a> { result } - pub(crate) fn consume_decorators(&mut self) -> oxc_allocator::Vec<'a, Decorator<'a>> { + pub(crate) fn consume_decorators(&mut self) -> Vec<'a, Decorator<'a>> { let decorators = std::mem::take(&mut self.state.decorators); self.ast.new_vec_from_iter(decorators) } @@ -340,7 +341,7 @@ impl<'a> ParserImpl<'a> { open: Kind, close: Kind, f: F, - ) -> Result> + ) -> Result> where F: Fn(&mut Self) -> Result>, { @@ -367,7 +368,7 @@ impl<'a> ParserImpl<'a> { separator: Kind, trailing_separator: bool, f: F, - ) -> Result> + ) -> Result> where F: Fn(&mut Self) -> Result, { @@ -393,4 +394,43 @@ impl<'a> ParserImpl<'a> { } Ok(list) } + + pub(crate) fn parse_delimited_list_with_rest( + &mut self, + close: Kind, + parse_element: E, + parse_rest: R, + ) -> Result<(Vec<'a, A>, Option)> + where + E: Fn(&mut Self) -> Result, + R: Fn(&mut Self) -> Result, + B: GetSpan, + { + let mut list = self.ast.new_vec(); + let mut rest = None; + let mut first = true; + loop { + let kind = self.cur_kind(); + if kind == close || kind == Kind::Eof { + break; + } + if first { + first = false; + } else { + self.expect(Kind::Comma)?; + if self.at(close) { + break; + } + } + + if self.at(Kind::Dot3) { + if let Some(r) = rest.replace(parse_rest(self)?) { + self.error(diagnostics::binding_rest_element_last(r.span())); + } + } else { + list.push(parse_element(self)?); + } + } + Ok((list, rest)) + } } diff --git a/crates/oxc_parser/src/js/binding.rs b/crates/oxc_parser/src/js/binding.rs index 6e6ccd9f1a4c..4594b39a7827 100644 --- a/crates/oxc_parser/src/js/binding.rs +++ b/crates/oxc_parser/src/js/binding.rs @@ -1,10 +1,8 @@ -use oxc_allocator::Box; use oxc_ast::ast::*; use oxc_diagnostics::Result; -use oxc_span::Span; +use oxc_span::{GetSpan, Span}; -use super::list::{ArrayPatternList, ObjectPatternProperties}; -use crate::{diagnostics, lexer::Kind, list::SeparatedList, Context, ParserImpl}; +use crate::{diagnostics, lexer::Kind, Context, ParserImpl}; impl<'a> ParserImpl<'a> { /// `BindingElement` @@ -46,19 +44,60 @@ impl<'a> ParserImpl<'a> { /// Section 14.3.3 Object Binding Pattern fn parse_object_binding_pattern(&mut self) -> Result> { let span = self.start_span(); - let props = ObjectPatternProperties::parse(self)?; - Ok(self.ast.object_pattern(self.end_span(span), props.elements, props.rest)) + self.expect(Kind::LCurly)?; + let (list, rest) = self.parse_delimited_list_with_rest( + Kind::RCurly, + Self::parse_binding_property, + Self::parse_rest_binding, + )?; + if let Some(rest) = &rest { + if !matches!(&rest.argument.kind, BindingPatternKind::BindingIdentifier(_)) { + return Err(diagnostics::invalid_binding_rest_element(rest.argument.span())); + } + } + self.expect(Kind::RCurly)?; + Ok(self.ast.object_pattern(self.end_span(span), list, rest.map(|r| self.ast.alloc(r)))) } /// Section 14.3.3 Array Binding Pattern fn parse_array_binding_pattern(&mut self) -> Result> { let span = self.start_span(); - let list = ArrayPatternList::parse(self)?; - Ok(self.ast.array_pattern(self.end_span(span), list.elements, list.rest)) + self.expect(Kind::LBrack)?; + let (list, rest) = self.parse_delimited_list_with_rest( + Kind::RBrack, + Self::parse_array_binding_element, + Self::parse_rest_binding, + )?; + self.expect(Kind::RBrack)?; + Ok(self.ast.array_pattern(self.end_span(span), list, rest.map(|r| self.ast.alloc(r)))) + } + + fn parse_array_binding_element(&mut self) -> Result>> { + if self.at(Kind::Comma) { + Ok(None) + } else { + self.parse_binding_pattern_with_initializer().map(Some) + } + } + + fn parse_rest_binding(&mut self) -> Result> { + // self.eat_decorators()?; + let elem = self.parse_rest_element()?; + if self.at(Kind::Comma) { + if matches!(self.peek_kind(), Kind::RCurly | Kind::RBrack) { + let span = self.cur_token().span(); + self.bump_any(); + self.error(diagnostics::binding_rest_element_trailing_comma(span)); + } + if !self.ctx.has_ambient() { + self.error(diagnostics::binding_rest_element_last(elem.span)); + } + } + Ok(elem) } /// Section 14.3.3 Binding Rest Property - pub(super) fn parse_rest_element(&mut self) -> Result>> { + pub(super) fn parse_rest_element(&mut self) -> Result> { let span = self.start_span(); self.bump_any(); // advance `...` let init_span = self.start_span(); @@ -73,22 +112,12 @@ impl<'a> ParserImpl<'a> { // The span is not extended to its type_annotation let type_annotation = self.parse_ts_type_annotation()?; let pattern = self.ast.binding_pattern(kind, type_annotation, false); - // Rest element does not allow `= initializer`, . + // Rest element does not allow `= initializer` let argument = self .context(Context::In, Context::empty(), |p| p.parse_initializer(init_span, pattern))?; let span = self.end_span(span); - if self.at(Kind::Comma) { - if self.peek_at(Kind::RBrack) { - self.error(diagnostics::binding_rest_element_trailing_comma( - self.cur_token().span(), - )); - } else if !self.ctx.has_ambient() { - self.error(diagnostics::binding_rest_element_last(span)); - } - } - - Ok(self.ast.rest_element(span, argument)) + Ok(BindingRestElement { span, argument }) } /// `BindingProperty`[Yield, Await] : diff --git a/crates/oxc_parser/src/js/function.rs b/crates/oxc_parser/src/js/function.rs index de82711a61c8..03cebbf62c20 100644 --- a/crates/oxc_parser/src/js/function.rs +++ b/crates/oxc_parser/src/js/function.rs @@ -5,11 +5,10 @@ use oxc_ast::ast::*; use oxc_diagnostics::Result; use oxc_span::Span; -use super::{list::FormalParameterList, FunctionKind}; +use super::FunctionKind; use crate::{ diagnostics, lexer::Kind, - list::SeparatedList, modifiers::{ModifierFlags, ModifierKind, Modifiers}, Context, ParserImpl, StatementContext, }; @@ -49,13 +48,74 @@ impl<'a> ParserImpl<'a> { params_kind: FormalParameterKind, ) -> Result<(Option>, Box<'a, FormalParameters<'a>>)> { let span = self.start_span(); - let list: FormalParameterList<'_> = FormalParameterList::parse(self)?; - let formal_parameters = - self.ast.formal_parameters(self.end_span(span), params_kind, list.elements, list.rest); - let this_param = list.this_param; + self.expect(Kind::LParen)?; + let this_param = if self.ts_enabled() && self.at(Kind::This) { + let param = self.parse_ts_this_parameter()?; + if !self.at(Kind::RParen) { + self.expect(Kind::Comma)?; + } + Some(param) + } else { + None + }; + let (list, rest) = self.parse_delimited_list_with_rest( + Kind::RParen, + Self::parse_formal_parameter, + Self::parse_rest_parameter, + )?; + self.expect(Kind::RParen)?; + let formal_parameters = self.ast.formal_parameters( + self.end_span(span), + params_kind, + list, + rest.map(|r| self.ast.alloc(r)), + ); Ok((this_param, formal_parameters)) } + fn parse_parameter_modifiers(&mut self) -> Modifiers<'a> { + let modifiers = self.parse_class_element_modifiers(true); + self.verify_modifiers( + &modifiers, + ModifierFlags::ACCESSIBILITY + .union(ModifierFlags::READONLY) + .union(ModifierFlags::OVERRIDE), + diagnostics::cannot_appear_on_a_parameter, + ); + modifiers + } + + fn parse_formal_parameter(&mut self) -> Result> { + let span = self.start_span(); + self.eat_decorators()?; + let modifiers = self.parse_parameter_modifiers(); + let pattern = self.parse_binding_pattern_with_initializer()?; + let decorators = self.consume_decorators(); + Ok(self.ast.formal_parameter( + self.end_span(span), + pattern, + modifiers.accessibility(), + modifiers.contains_readonly(), + modifiers.contains_override(), + decorators, + )) + } + + fn parse_rest_parameter(&mut self) -> Result> { + let element = self.parse_rest_element()?; + if self.at(Kind::Comma) { + if matches!(self.peek_kind(), Kind::RCurly | Kind::RBrack) { + let span = self.cur_token().span(); + self.bump_any(); + self.error(diagnostics::binding_rest_element_trailing_comma(span)); + } + if !self.ctx.has_ambient() { + self.error(diagnostics::rest_parameter_last(element.span)); + } + } + Ok(element) + } + pub(crate) fn parse_function( &mut self, span: Span, diff --git a/crates/oxc_parser/src/js/list.rs b/crates/oxc_parser/src/js/list.rs deleted file mode 100644 index 119f50b31259..000000000000 --- a/crates/oxc_parser/src/js/list.rs +++ /dev/null @@ -1,148 +0,0 @@ -use oxc_allocator::Vec; -use oxc_ast::ast::*; -use oxc_diagnostics::Result; -use oxc_span::GetSpan; - -use crate::{diagnostics, lexer::Kind, list::SeparatedList, modifiers::ModifierFlags, ParserImpl}; - -/// ObjectPattern.properties -pub struct ObjectPatternProperties<'a> { - pub elements: Vec<'a, BindingProperty<'a>>, - pub rest: Option>>, -} - -impl<'a> SeparatedList<'a> for ObjectPatternProperties<'a> { - fn new(p: &ParserImpl<'a>) -> Self { - Self { elements: p.ast.new_vec(), rest: None } - } - - fn open(&self) -> Kind { - Kind::LCurly - } - - fn close(&self) -> Kind { - Kind::RCurly - } - - fn parse_element(&mut self, p: &mut ParserImpl<'a>) -> Result<()> { - if p.cur_kind() == Kind::Dot3 { - let rest = p.parse_rest_element()?; - if !matches!(&rest.argument.kind, BindingPatternKind::BindingIdentifier(_)) { - p.error(diagnostics::invalid_binding_rest_element(rest.argument.span())); - } - if let Some(r) = self.rest.replace(rest) { - p.error(diagnostics::binding_rest_element_last(r.span)); - } - } else { - let prop = p.parse_binding_property()?; - self.elements.push(prop); - } - Ok(()) - } -} - -/// ArrayPattern.elements -pub struct ArrayPatternList<'a> { - pub elements: Vec<'a, Option>>, - pub rest: Option>>, -} - -impl<'a> SeparatedList<'a> for ArrayPatternList<'a> { - fn new(p: &ParserImpl<'a>) -> Self { - Self { elements: p.ast.new_vec(), rest: None } - } - - fn open(&self) -> Kind { - Kind::LBrack - } - - fn close(&self) -> Kind { - Kind::RBrack - } - - fn parse_element(&mut self, p: &mut ParserImpl<'a>) -> Result<()> { - match p.cur_kind() { - Kind::Comma => { - self.elements.push(None); - } - Kind::Dot3 => { - let rest = p.parse_rest_element()?; - if let Some(r) = self.rest.replace(rest) { - p.error(diagnostics::binding_rest_element_last(r.span)); - } - } - _ => { - let element = p.parse_binding_pattern_with_initializer()?; - self.elements.push(Some(element)); - } - } - Ok(()) - } -} - -/// Function Parameters -pub struct FormalParameterList<'a> { - pub elements: Vec<'a, FormalParameter<'a>>, - pub rest: Option>>, - pub this_param: Option>, -} - -impl<'a> SeparatedList<'a> for FormalParameterList<'a> { - fn new(p: &ParserImpl<'a>) -> Self { - Self { elements: p.ast.new_vec(), rest: None, this_param: None } - } - - fn open(&self) -> Kind { - Kind::LParen - } - - fn close(&self) -> Kind { - Kind::RParen - } - - // Section 15.1 Parameter Lists - fn parse_element(&mut self, p: &mut ParserImpl<'a>) -> Result<()> { - let span = p.start_span(); - p.eat_decorators()?; - - let modifiers = p.parse_class_element_modifiers(true); - let accessibility = modifiers.accessibility(); - let readonly = modifiers.contains_readonly(); - let r#override = modifiers.contains_override(); - p.verify_modifiers( - &modifiers, - ModifierFlags::ACCESSIBILITY - .union(ModifierFlags::READONLY) - .union(ModifierFlags::OVERRIDE), - diagnostics::cannot_appear_on_a_parameter, - ); - - match p.cur_kind() { - Kind::This if p.ts_enabled() => { - let this_parameter = p.parse_ts_this_parameter()?; - self.this_param.replace(this_parameter); - } - Kind::Dot3 => { - let rest = p.parse_rest_element()?; - if let Some(r) = self.rest.replace(rest) { - p.error(diagnostics::rest_parameter_last(r.span)); - } - } - _ => { - let pattern = p.parse_binding_pattern_with_initializer()?; - let decorators = p.consume_decorators(); - let formal_parameter = p.ast.formal_parameter( - p.end_span(span), - pattern, - accessibility, - readonly, - r#override, - decorators, - ); - self.elements.push(formal_parameter); - } - } - - Ok(()) - } -} diff --git a/crates/oxc_parser/src/js/mod.rs b/crates/oxc_parser/src/js/mod.rs index 27f4667bf48d..41133dab4586 100644 --- a/crates/oxc_parser/src/js/mod.rs +++ b/crates/oxc_parser/src/js/mod.rs @@ -3,7 +3,6 @@ #![allow(clippy::missing_errors_doc)] mod grammar; -pub mod list; mod arrow; mod binding; diff --git a/crates/oxc_parser/src/lib.rs b/crates/oxc_parser/src/lib.rs index 2fba591e8913..e30ba847c534 100644 --- a/crates/oxc_parser/src/lib.rs +++ b/crates/oxc_parser/src/lib.rs @@ -63,7 +63,6 @@ mod context; mod cursor; -mod list; mod modifiers; mod state; diff --git a/crates/oxc_parser/src/list.rs b/crates/oxc_parser/src/list.rs deleted file mode 100644 index 5d31b64d7f63..000000000000 --- a/crates/oxc_parser/src/list.rs +++ /dev/null @@ -1,49 +0,0 @@ -use oxc_diagnostics::Result; - -use crate::{lexer::Kind, ParserImpl}; - -pub trait SeparatedList<'a>: Sized { - fn new(p: &ParserImpl<'a>) -> Self; - - fn parse(p: &mut ParserImpl<'a>) -> Result { - let mut list = Self::new(p); - list.parse_list(p)?; - Ok(list) - } - - /// Open element, e.g.. `{` `[` `(` - fn open(&self) -> Kind; - - /// Close element, e.g.. `}` `]` `)` - fn close(&self) -> Kind; - - /// Separator element, e.g. `,` - fn separator(&self) -> Kind { - Kind::Comma - } - - fn parse_element(&mut self, p: &mut ParserImpl<'a>) -> Result<()>; - - /// Main entry point, parse the list - fn parse_list(&mut self, p: &mut ParserImpl<'a>) -> Result<()> { - p.expect(self.open())?; - - let mut first = true; - - while !p.at(self.close()) && !p.at(Kind::Eof) { - if first { - first = false; - } else { - p.expect(self.separator())?; - if p.at(self.close()) { - break; - } - } - - self.parse_element(p)?; - } - - p.expect(self.close())?; - Ok(()) - } -} diff --git a/crates/oxc_parser/src/ts/statement.rs b/crates/oxc_parser/src/ts/statement.rs index d9673bd7a833..23b2b9da9c67 100644 --- a/crates/oxc_parser/src/ts/statement.rs +++ b/crates/oxc_parser/src/ts/statement.rs @@ -439,12 +439,12 @@ impl<'a> ParserImpl<'a> { pub(crate) fn parse_ts_this_parameter(&mut self) -> Result> { let span = self.start_span(); - + self.parse_class_element_modifiers(true); + self.eat_decorators()?; let this = { let (span, name) = self.parse_identifier_kind(Kind::This); IdentifierName { span, name } }; - let type_annotation = self.parse_ts_type_annotation()?; Ok(self.ast.ts_this_parameter(self.end_span(span), this, type_annotation)) } diff --git a/tasks/coverage/parser_babel.snap b/tasks/coverage/parser_babel.snap index 32a146dee58e..bcc3d0ab8e95 100644 --- a/tasks/coverage/parser_babel.snap +++ b/tasks/coverage/parser_babel.snap @@ -1439,7 +1439,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[core/uncategorised/396/input.js:1:12] 1 │ function t(...rest, b) { } · ─────── @@ -2289,7 +2289,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[core/uncategorised/555/input.js:3:5] 2 │ first, 3 │ ...second, @@ -2321,7 +2321,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ──── ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[es2015/arrow-functions/comma-after-rest-param/input.js:1:2] 1 │ (...rest,) => {} · ─────── @@ -2383,7 +2383,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Try insert a semicolon here - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[es2015/arrow-functions/invalid-rest-in-params/input.js:3:5] 2 │ first, 3 │ ...second, @@ -3984,7 +3984,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[es2015/uncategorised/277/input.js:1:15] 1 │ function f(a, ...b, c) { } · ──── @@ -4011,7 +4011,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ╰── `a` has already been declared here ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[es2015/uncategorised/283/input.js:1:2] 1 │ (...a, b) => {} · ──── @@ -5191,7 +5191,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 3 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[es2017/async-functions/params-invalid-rest-trailing-comma/input.js:1:8] 1 │ async (...a,) => {}; · ──── @@ -5441,6 +5441,12 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ──── ╰──── + × Unexpected trailing comma after rest element + ╭─[es2018/object-rest-spread/8/input.js:1:17] + 1 │ let { x, y, ...z, } = obj; + · ─ + ╰──── + × A rest element must be last in a destructuring pattern ╭─[es2018/object-rest-spread/8/input.js:1:13] 1 │ let { x, y, ...z, } = obj; @@ -6971,6 +6977,12 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── + × A rest element must be last in a destructuring pattern + ╭─[esprima/es2015-array-binding-pattern/invalid-elision-after-rest/input.js:1:5] + 1 │ ([a,...b,])=>0; + · ──── + ╰──── + × Identifier `a` has already been declared ╭─[esprima/es2015-array-pattern/dupe-param-1/input.js:2:13] 1 │ "use strict"; @@ -7012,13 +7024,13 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ╰── `,` expected ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[esprima/es2015-arrow-function/arrow-with-multiple-rest/input.js:1:2] 1 │ (...a, ...b) => 0 · ──── ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[esprima/es2015-arrow-function/arrow-with-multiple-rest/input.js:1:2] 1 │ (...a, ...b) => 0 · ──── @@ -9574,7 +9586,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: Try insert a semicolon here - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[esprima/invalid-syntax/migrated_0258/input.js:1:15] 1 │ function f(a, ...b, c){} · ──── diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index 7e1f3f694f16..67c9743c10d3 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -2126,7 +2126,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 131 │ }; ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/arrow-function/rest-params-trailing-comma-early-error.js:54:5] 53 │ 54 │ 0, (...a,) => { @@ -5392,7 +5392,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 123 │ }); ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/async-arrow-function/rest-params-trailing-comma-early-error.js:46:9] 45 │ 46 │ (async (...a,) => { @@ -5651,7 +5651,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 109 │ }); ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/async-function/named-rest-params-trailing-comma-early-error.js:33:19] 32 │ 33 │ (async function f(...a,) { @@ -5701,7 +5701,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 109 │ }); ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/async-function/nameless-rest-params-trailing-comma-early-error.js:33:17] 32 │ 33 │ (async function(...a,) { @@ -6275,7 +6275,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 112 │ }; ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/async-generator/named-rest-params-trailing-comma-early-error.js:36:22] 35 │ 36 │ 0, async function* g(...a,) { @@ -6405,7 +6405,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 112 │ }; ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/async-generator/rest-params-trailing-comma-early-error.js:36:20] 35 │ 36 │ 0, async function*(...a,) { @@ -6656,7 +6656,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 136 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/async-gen-method/rest-params-trailing-comma-early-error.js:60:17] 59 │ 0, class { 60 │ async *method(...a,) { @@ -6876,7 +6876,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 136 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/async-gen-method-static/rest-params-trailing-comma-early-error.js:60:24] 59 │ 0, class { 60 │ static async *method(...a,) { @@ -7096,7 +7096,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 134 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/async-method/rest-params-trailing-comma-early-error.js:57:23] 56 │ var C = class { 57 │ static async method(...a,) { @@ -7210,7 +7210,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 134 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/async-method-static/rest-params-trailing-comma-early-error.js:57:23] 56 │ var C = class { 57 │ static async method(...a,) { @@ -12223,7 +12223,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 157 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/gen-method/rest-params-trailing-comma-early-error.js:81:11] 80 │ 0, class { 81 │ *method(...a,) { @@ -12388,7 +12388,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 157 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/gen-method-static/rest-params-trailing-comma-early-error.js:81:18] 80 │ 0, class { 81 │ static *method(...a,) { @@ -12551,7 +12551,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 153 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/method/rest-params-trailing-comma-early-error.js:76:10] 75 │ 0, class { 76 │ method(...a,) { @@ -12609,7 +12609,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 153 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/class/method-static/rest-params-trailing-comma-early-error.js:76:17] 75 │ 0, class { 76 │ static method(...a,) { @@ -14122,7 +14122,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 132 │ }; ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/function/rest-params-trailing-comma-early-error.js:55:13] 54 │ 55 │ 0, function(...a,) { @@ -14390,7 +14390,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 133 │ }; ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/generators/rest-params-trailing-comma-early-error.js:57:14] 56 │ 57 │ 0, function*(...a,) { @@ -15439,7 +15439,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 117 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/object/method-definition/async-gen-meth-rest-params-trailing-comma-early-error.js:41:17] 40 │ 0, { 41 │ async *method(...a,) { @@ -15603,7 +15603,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 110 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/object/method-definition/async-meth-rest-params-trailing-comma-early-error.js:34:17] 33 │ ({ 34 │ async *method(...a,) { @@ -15811,7 +15811,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 139 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/object/method-definition/gen-meth-rest-params-trailing-comma-early-error.js:63:11] 62 │ 0, { 63 │ *method(...a,) { @@ -16032,7 +16032,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 135 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/expressions/object/method-definition/meth-rest-params-trailing-comma-early-error.js:58:10] 57 │ 0, { 58 │ method(...a,) { @@ -20955,7 +20955,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" ╰──── help: Try insert a semicolon here - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/rest-parameters/position-invalid.js:13:15] 12 │ $DONOTEVALUATE(); 13 │ function f(a, ...b, c) {} @@ -21189,7 +21189,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 109 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/async-function/rest-params-trailing-comma-early-error.js:33:18] 32 │ 33 │ async function f(...a,) { @@ -21406,7 +21406,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 112 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/async-generator/rest-params-trailing-comma-early-error.js:36:19] 35 │ 36 │ async function* f(...a,) { @@ -21859,7 +21859,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 135 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/async-gen-method/rest-params-trailing-comma-early-error.js:59:17] 58 │ class C { 59 │ async *method(...a,) { @@ -22079,7 +22079,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 136 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js:60:24] 59 │ class C { 60 │ static async *method(...a,) { @@ -22307,7 +22307,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 134 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/async-method/rest-params-trailing-comma-early-error.js:57:16] 56 │ class C { 57 │ async method(...a,) { @@ -22421,7 +22421,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 133 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/async-method-static/rest-params-trailing-comma-early-error.js:56:23] 55 │ class C { 56 │ static async method(...a,) { @@ -27645,7 +27645,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 155 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/gen-method/rest-params-trailing-comma-early-error.js:79:11] 78 │ class C { 79 │ *method(...a,) { @@ -27810,7 +27810,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 155 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/gen-method-static/rest-params-trailing-comma-early-error.js:79:18] 78 │ class C { 79 │ static *method(...a,) { @@ -27973,7 +27973,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 152 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/method/rest-params-trailing-comma-early-error.js:75:10] 74 │ class C { 75 │ method(...a,) { @@ -28031,7 +28031,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 152 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/class/method-static/rest-params-trailing-comma-early-error.js:75:17] 74 │ class C { 75 │ static method(...a,) { @@ -31637,7 +31637,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 133 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/function/rest-params-trailing-comma-early-error.js:56:12] 55 │ 56 │ function f(...a,) { @@ -31807,7 +31807,7 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" 133 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[language/statements/generators/rest-params-trailing-comma-early-error.js:57:13] 56 │ 57 │ function* f(...a,) { diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 6d6c34c1f077..a6e2a90b9fcc 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,9 +1,9 @@ commit: d8086f14 parser_typescript Summary: -AST Parsed : 5280/5283 (99.94%) -Positive Passed: 5273/5283 (99.81%) -Negative Passed: 1077/4875 (22.09%) +AST Parsed : 5279/5283 (99.92%) +Positive Passed: 5272/5283 (99.79%) +Negative Passed: 1082/4875 (22.19%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -1510,7 +1510,6 @@ Expect Syntax Error: "compiler/reservedNameOnModuleImportWithInterface.ts" Expect Syntax Error: "compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts" Expect Syntax Error: "compiler/restArgAssignmentCompat.ts" Expect Syntax Error: "compiler/restInvalidArgumentType.ts" -Expect Syntax Error: "compiler/restParamModifier2.ts" Expect Syntax Error: "compiler/restParamsWithNonRestParams.ts" Expect Syntax Error: "compiler/restUnion3.ts" Expect Syntax Error: "compiler/returnInConstructor1.ts" @@ -1899,7 +1898,6 @@ Expect Syntax Error: "compiler/useBeforeDeclaration_propertyAssignment.ts" Expect Syntax Error: "compiler/useBeforeDeclaration_superClass.ts" Expect Syntax Error: "compiler/useUnknownInCatchVariables01.ts" Expect Syntax Error: "compiler/varAndFunctionShareName.ts" -Expect Syntax Error: "compiler/varArgConstructorMemberParameter.ts" Expect Syntax Error: "compiler/varBlock.ts" Expect Syntax Error: "compiler/varNameConflictsWithImportInDifferentPartOfModule.ts" Expect Syntax Error: "compiler/vararg.ts" @@ -2188,7 +2186,6 @@ Expect Syntax Error: "conformance/decorators/class/method/decoratorOnClassMethod Expect Syntax Error: "conformance/decorators/class/method/decoratorOnClassMethod6.ts" Expect Syntax Error: "conformance/decorators/class/method/decoratorOnClassMethod8.ts" Expect Syntax Error: "conformance/decorators/class/method/decoratorOnClassMethodOverload1.ts" -Expect Syntax Error: "conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts" Expect Syntax Error: "conformance/decorators/class/property/decoratorOnClassProperty11.ts" Expect Syntax Error: "conformance/decorators/class/property/decoratorOnClassProperty6.ts" Expect Syntax Error: "conformance/decorators/class/property/decoratorOnClassProperty7.ts" @@ -2196,7 +2193,6 @@ Expect Syntax Error: "conformance/decorators/decoratorCallGeneric.ts" Expect Syntax Error: "conformance/decorators/invalid/decoratorOnEnum.ts" Expect Syntax Error: "conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts" Expect Syntax Error: "conformance/decorators/invalid/decoratorOnFunctionExpression.ts" -Expect Syntax Error: "conformance/decorators/invalid/decoratorOnFunctionParameter.ts" Expect Syntax Error: "conformance/decorators/invalid/decoratorOnImportEquals1.ts" Expect Syntax Error: "conformance/decorators/invalid/decoratorOnInterface.ts" Expect Syntax Error: "conformance/decorators/invalid/decoratorOnInternalModule.ts" @@ -3175,7 +3171,6 @@ Expect Syntax Error: "conformance/parser/ecmascript5/Protected/Protected7.ts" Expect Syntax Error: "conformance/parser/ecmascript5/RealWorld/parserindenter.ts" Expect Syntax Error: "conformance/parser/ecmascript5/RegressionTests/parser509534.ts" Expect Syntax Error: "conformance/parser/ecmascript5/RegressionTests/parser509618.ts" -Expect Syntax Error: "conformance/parser/ecmascript5/RegressionTests/parser509668.ts" Expect Syntax Error: "conformance/parser/ecmascript5/RegressionTests/parser509693.ts" Expect Syntax Error: "conformance/parser/ecmascript5/RegressionTests/parser509698.ts" Expect Syntax Error: "conformance/parser/ecmascript5/RegressionTests/parser536727.ts" @@ -3818,6 +3813,15 @@ Expect to Parse: "compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts" · ──── 24 │ const enum H {} ╰──── +Expect to Parse: "compiler/sourceMapValidationDecorators.ts" + + × Unexpected token + ╭─[compiler/sourceMapValidationDecorators.ts:18:7] + 17 │ @ParameterDecorator2(30) + 18 │ ...b: string[]) { + · ─── + 19 │ } + ╰──── Expect to Parse: "compiler/withStatementInternalComments.ts" × 'with' statements are not allowed @@ -8995,7 +8999,15 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 3 │ } ╰──── - × A rest element must be last in a destructuring pattern + × Unexpected token + ╭─[compiler/restParamModifier2.ts:2:24] + 1 │ class C { + 2 │ constructor(public ...rest: string[]) {} + · ─── + 3 │ } + ╰──── + + × A rest parameter must be last in a parameter list ╭─[compiler/restParameterNotLast.ts:1:12] 1 │ function f(...x, y) { } · ──── @@ -10530,6 +10542,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── help: Try insert a semicolon here + × Unexpected token + ╭─[compiler/varArgConstructorMemberParameter.ts:10:25] + 9 │ class Foo3 { + 10 │ constructor (public ...args: string[]) { } + · ─── + 11 │ } + ╰──── + × Unexpected token ╭─[compiler/varArgWithNoParamName.ts:1:16] 1 │ function t1(...) {} @@ -12553,6 +12573,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 6 │ } ╰──── + × Unexpected token + ╭─[conformance/decorators/class/method/parameter/decoratorOnClassMethodThisParameter.ts:4:17] + 3 │ class C { + 4 │ method(@dec this: C) {} + · ──── + 5 │ } + ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[conformance/decorators/class/property/decoratorOnClassProperty3.ts:4:11] 3 │ class C { @@ -12586,6 +12614,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 5 │ } ╰──── + × Unexpected token + ╭─[conformance/decorators/invalid/decoratorOnFunctionParameter.ts:5:22] + 4 │ + 5 │ function direct(@dec this: C) { return this.n; } + · ──── + 6 │ function called(@dec() this: C) { return this.n; } + ╰──── + × Unexpected token ╭─[conformance/dynamicImport/importCallExpressionGrammarError.ts:5:8] 4 │ var a = ["./0"]; @@ -13004,12 +13040,12 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 15 │ function a4(...b = [1,2,3]) { } // Error, can't have initializer ╰──── - × A rest parameter cannot have an initializer - ╭─[conformance/es6/destructuring/destructuringParameterDeclaration4.ts:15:16] - 14 │ function a3(...b?) { } // Error, can't be optional - 15 │ function a4(...b = [1,2,3]) { } // Error, can't have initializer - · ─────────── - 16 │ function a5([a, b, [[c]]]) { } + × Unexpected token + ╭─[conformance/es6/destructuring/destructuringParameterDeclaration4.ts:29:24] + 28 │ class C { + 29 │ constructor(public ...temp) { } // Error, rest parameter can't have properties + · ─── + 30 │ } ╰──── × Expected `:` but found `}` @@ -15528,6 +15564,21 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 2 │ const {...b,} = {}; ╰──── + × A rest element must be last in a destructuring pattern + ╭─[conformance/es7/trailingCommasInBindingPatterns.ts:1:8] + 1 │ const [...a,] = []; + · ──── + 2 │ const {...b,} = {}; + ╰──── + + × Unexpected trailing comma after rest element + ╭─[conformance/es7/trailingCommasInBindingPatterns.ts:2:12] + 1 │ const [...a,] = []; + 2 │ const {...b,} = {}; + · ─ + 3 │ let c, d; + ╰──── + × A rest element must be last in a destructuring pattern ╭─[conformance/es7/trailingCommasInBindingPatterns.ts:2:8] 1 │ const [...a,] = []; @@ -15544,7 +15595,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 5 │ ({...d,} = {}); ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/es7/trailingCommasInFunctionParametersAndArguments.ts:5:13] 4 │ 5 │ function f2(...args,) {} @@ -16214,7 +16265,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 12 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/functions/functionOverloadErrorsSyntax.ts:9:25] 8 │ //Function overload signature with rest param followed by non-optional parameter 9 │ function fn5(x: string, ...y: any[], z: string); @@ -17888,7 +17939,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 4 │ }; ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/parser/ecmascript5/ParameterLists/parserParameterList1.ts:2:6] 1 │ class C { 2 │ F(...A, B) { } @@ -17995,6 +18046,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 5 │ ╰──── + × Unexpected token + ╭─[conformance/parser/ecmascript5/RegressionTests/parser509668.ts:3:23] + 2 │ // Doesn't work, but should + 3 │ constructor (public ...args: string[]) { } + · ─── + 4 │ } + ╰──── + × Empty parenthesized expression ╭─[conformance/parser/ecmascript5/RegressionTests/parser509669.ts:2:9] 1 │ function foo():any { @@ -20586,7 +20645,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 36 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts:5:11] 4 │ var f = function foo(...x) { } 5 │ var f2 = (...x, ...y) => { } @@ -20594,7 +20653,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 6 │ ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts:5:11] 4 │ var f = function foo(...x) { } 5 │ var f2 = (...x, ...y) => { } @@ -20602,7 +20661,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 6 │ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts:13:9] 12 │ (...x); 13 │ foo(...x, ...y); @@ -20610,7 +20669,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 14 │ } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts:13:9] 12 │ (...x); 13 │ foo(...x, ...y); @@ -20618,7 +20677,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 14 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts:23:21] 22 │ foo(...x) { }, 23 │ a: function foo(...x, ...y) { }, @@ -20626,7 +20685,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 24 │ b: (...x) => { } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts:23:21] 22 │ foo(...x) { }, 23 │ a: function foo(...x, ...y) { }, @@ -20634,7 +20693,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 24 │ b: (...x) => { } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts:5:11] 4 │ var f = function foo(...x: number) { } 5 │ var f2 = (...x: Date, ...y: boolean) => { } @@ -20642,7 +20701,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 6 │ ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts:5:11] 4 │ var f = function foo(...x: number) { } 5 │ var f2 = (...x: Date, ...y: boolean) => { } @@ -20650,7 +20709,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 6 │ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts:13:9] 12 │ (...x: string); 13 │ foo(...x: number, ...y: number); @@ -20658,7 +20717,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 14 │ } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts:13:9] 12 │ (...x: string); 13 │ foo(...x: number, ...y: number); @@ -20666,7 +20725,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 14 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts:23:21] 22 │ foo(...x: string) { }, 23 │ a: function foo(...x: number, ...y: Date) { }, @@ -20674,7 +20733,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 24 │ b: (...x: string) => { } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts:23:21] 22 │ foo(...x: string) { }, 23 │ a: function foo(...x: number, ...y: Date) { }, @@ -20682,7 +20741,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 24 │ b: (...x: string) => { } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:9:11] 8 │ var f = function foo(...x: MyThing) { } 9 │ var f2 = (...x: MyThing, ...y: MyThing) => { } @@ -20690,7 +20749,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 10 │ ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:9:11] 8 │ var f = function foo(...x: MyThing) { } 9 │ var f2 = (...x: MyThing, ...y: MyThing) => { } @@ -20698,7 +20757,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 10 │ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:17:9] 16 │ (...x: MyThing); 17 │ foo(...x: MyThing, ...y: MyThing); @@ -20706,7 +20765,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 18 │ } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:17:9] 16 │ (...x: MyThing); 17 │ foo(...x: MyThing, ...y: MyThing); @@ -20714,7 +20773,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 18 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:27:21] 26 │ foo(...x: MyThing) { }, 27 │ a: function foo(...x: MyThing, ...y: MyThing) { }, @@ -20722,7 +20781,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 28 │ b: (...x: MyThing) => { } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:27:21] 26 │ foo(...x: MyThing) { }, 27 │ a: function foo(...x: MyThing, ...y: MyThing) { }, @@ -20730,7 +20789,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 28 │ b: (...x: MyThing) => { } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:36:11] 35 │ var f3 = function foo(...x: MyThing2) { } 36 │ var f4 = (...x: MyThing2, ...y: MyThing2) => { } @@ -20738,7 +20797,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 37 │ ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:36:11] 35 │ var f3 = function foo(...x: MyThing2) { } 36 │ var f4 = (...x: MyThing2, ...y: MyThing2) => { } @@ -20746,7 +20805,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 37 │ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:44:9] 43 │ (...x: MyThing2); 44 │ foo(...x: MyThing2, ...y: MyThing2); @@ -20754,7 +20813,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 45 │ } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:44:9] 43 │ (...x: MyThing2); 44 │ foo(...x: MyThing2, ...y: MyThing2); @@ -20762,7 +20821,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 45 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:54:21] 53 │ foo(...x: MyThing2) { }, 54 │ a: function foo(...x: MyThing2, ...y: MyThing2) { }, @@ -20770,7 +20829,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 55 │ b: (...x: MyThing2) => { } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts:54:21] 53 │ foo(...x: MyThing2) { }, 54 │ a: function foo(...x: MyThing2, ...y: MyThing2) { }, @@ -20778,7 +20837,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 55 │ b: (...x: MyThing2) => { } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:5:11] 4 │ var f = function foo(...x: number[]) { } 5 │ var f2 = (...x: number[], ...y: number[]) => { } @@ -20786,7 +20845,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 6 │ ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:5:11] 4 │ var f = function foo(...x: number[]) { } 5 │ var f2 = (...x: number[], ...y: number[]) => { } @@ -20794,7 +20853,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 6 │ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:13:9] 12 │ (...x: number[]); 13 │ foo(...x: number[], ...y: number[]); @@ -20802,7 +20861,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 14 │ } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:13:9] 12 │ (...x: number[]); 13 │ foo(...x: number[], ...y: number[]); @@ -20810,7 +20869,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 14 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:23:21] 22 │ foo(...x: number[]) { }, 23 │ a: function foo(...x: number[], ...y: number[]) { }, @@ -20818,7 +20877,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 24 │ b: (...x: number[]) => { } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:23:21] 22 │ foo(...x: number[]) { }, 23 │ a: function foo(...x: number[], ...y: number[]) { }, @@ -20826,7 +20885,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 24 │ b: (...x: number[]) => { } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:32:11] 31 │ var f3 = function foo(...x: Array) { } 32 │ var f4 = (...x: Array, ...y: Array) => { } @@ -20834,7 +20893,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 33 │ ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:32:11] 31 │ var f3 = function foo(...x: Array) { } 32 │ var f4 = (...x: Array, ...y: Array) => { } @@ -20842,7 +20901,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 33 │ ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:40:9] 39 │ (...x: Array); 40 │ foo(...x: Array, ...y: Array); @@ -20850,7 +20909,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 41 │ } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:40:9] 39 │ (...x: Array); 40 │ foo(...x: Array, ...y: Array); @@ -20858,7 +20917,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 41 │ } ╰──── - × A rest element must be last in a destructuring pattern + × A rest parameter must be last in a parameter list ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:50:21] 49 │ foo(...x: Array) { }, 50 │ a: function foo(...x: Array, ...y: Array) { }, @@ -20866,7 +20925,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 51 │ b: (...x: Array) => { } ╰──── - × A rest parameter must be last in a parameter list + × A rest element must be last in a destructuring pattern ╭─[conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts:50:21] 49 │ foo(...x: Array) { }, 50 │ a: function foo(...x: Array, ...y: Array) { }, @@ -21020,13 +21079,12 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 165 │ function notFirst(a: number, this: C): number { return this.n; } ╰──── - × Expected `,` but found `this` - ╭─[conformance/types/thisType/thisTypeInFunctionsNegative.ts:168:26] - 167 │ ///// parse errors ///// - 168 │ function modifiers(async this: C): number { return this.n; } - · ──┬─ - · ╰── `,` expected - 169 │ function restParam(...this: C): number { return this.n; } + × Unexpected token + ╭─[conformance/types/thisType/thisTypeInFunctionsNegative.ts:165:30] + 164 │ var thisConstructorType: new (this: number) => number; + 165 │ function notFirst(a: number, this: C): number { return this.n; } + · ──── + 166 │ ╰──── × Expected a semicolon or an implicit semicolon after a statement, but found none diff --git a/tasks/coverage/prettier_typescript.snap b/tasks/coverage/prettier_typescript.snap index 1bdc895b0a81..80d1ef63e690 100644 --- a/tasks/coverage/prettier_typescript.snap +++ b/tasks/coverage/prettier_typescript.snap @@ -2,7 +2,7 @@ commit: d8086f14 prettier_typescript Summary: AST Parsed : 5283/5283 (100.00%) -Positive Passed: 2447/5283 (46.32%) +Positive Passed: 2448/5283 (46.34%) Expect to Parse: "compiler/DeclarationErrorsNoEmitOnError.ts" Expect to Parse: "compiler/abstractInterfaceIdentifierName.ts" Expect to Parse: "compiler/abstractPropertyBasics.ts" @@ -1408,7 +1408,6 @@ Expect to Parse: "compiler/sourceMap-FileWithComments.ts" Expect to Parse: "compiler/sourceMap-StringLiteralWithNewLine.ts" Expect to Parse: "compiler/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.ts" Expect to Parse: "compiler/sourceMapValidationClasses.ts" -Expect to Parse: "compiler/sourceMapValidationDecorators.ts" Expect to Parse: "compiler/sourceMapValidationDestructuringForArrayBindingPattern.ts" Expect to Parse: "compiler/sourceMapValidationDestructuringForArrayBindingPattern2.ts" Expect to Parse: "compiler/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.ts"