From 998d151589757fd85419b56379cf6ba197f3504a Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 15:32:26 +0100 Subject: [PATCH 01/23] wip --- .gitignore | 3 + crates/oxc_ast/src/ast/js.rs | 13 + crates/oxc_ast/src/ast_builder.rs | 22 ++ crates/oxc_ast/src/ast_kind.rs | 6 + crates/oxc_ast/src/span.rs | 3 + .../oxc_ast/src/syntax_directed_operations.rs | 8 + crates/oxc_ast/src/visit.rs | 16 + crates/oxc_ast/src/visit_mut.rs | 13 + crates/oxc_formatter/src/gen.rs | 18 ++ crates/oxc_minifier/src/printer/gen.rs | 18 ++ crates/oxc_parser/src/diagnostics.rs | 10 + crates/oxc_parser/src/js/declaration.rs | 46 +++ crates/oxc_parser/src/lexer/kind.rs | 3 + crates/oxc_parser/src/lexer/mod.rs | 1 + .../src/statements_and_declarations.rs | 4 + tasks/coverage/parser_typescript.snap | 303 +++++++++++++++++- tasks/coverage/test262 | 2 +- tasks/coverage/typescript | 2 +- 18 files changed, 473 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 611e7592de5b..2fb49770b582 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ crates/oxc_napi/*.node /*.jsx /*.ts /*.tsx + +# MacOS +.DS_Store \ No newline at end of file diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 233b734bc3fd..babecb2837a1 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -993,6 +993,7 @@ pub enum Declaration<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>), FunctionDeclaration(Box<'a, Function<'a>>), ClassDeclaration(Box<'a, Class<'a>>), + UsingDeclaration(Box<'a, UsingDeclaration<'a>>), TSTypeAliasDeclaration(Box<'a, TSTypeAliasDeclaration<'a>>), TSInterfaceDeclaration(Box<'a, TSInterfaceDeclaration<'a>>), @@ -1134,6 +1135,7 @@ pub struct ForStatement<'a> { pub enum ForStatementInit<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>), Expression(Expression<'a>), + UsingDeclaration(Box<'a, UsingDeclaration<'a>>), } impl<'a> ForStatementInit<'a> { @@ -1172,6 +1174,7 @@ pub struct ForOfStatement<'a> { pub enum ForStatementLeft<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>), AssignmentTarget(AssignmentTarget<'a>), + UsingDeclaration(Box<'a, UsingDeclaration<'a>>), } impl<'a> ForStatementLeft<'a> { @@ -1952,3 +1955,13 @@ impl ModuleExportName { } } } + +#[derive(Debug, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "camelCase"))] +pub struct UsingDeclaration<'a> { + #[cfg_attr(feature = "serde", serde(flatten))] + pub span: Span, + pub is_await: bool, + #[cfg_attr(feature = "serde-impl", serde(default))] + pub declarations: Vec<'a, VariableDeclarator<'a>>, +} diff --git a/crates/oxc_ast/src/ast_builder.rs b/crates/oxc_ast/src/ast_builder.rs index 6b911748e423..a7f3951ec4a1 100644 --- a/crates/oxc_ast/src/ast_builder.rs +++ b/crates/oxc_ast/src/ast_builder.rs @@ -151,6 +151,19 @@ impl<'a> AstBuilder<'a> { Statement::DebuggerStatement(self.alloc(DebuggerStatement { span })) } + pub fn using_statement( + &self, + span: Span, + declarations: Vec<'a, VariableDeclarator<'a>>, + is_await: bool, + ) -> Statement<'a> { + Statement::Declaration(Declaration::UsingDeclaration(self.alloc(UsingDeclaration { + span, + is_await, + declarations, + }))) + } + pub fn do_while_statement( &self, span: Span, @@ -742,6 +755,15 @@ impl<'a> AstBuilder<'a> { VariableDeclarator { span, kind, id, init, definite } } + pub fn using_declaration( + &self, + span: Span, + declarations: Vec<'a, VariableDeclarator<'a>>, + is_await: bool, + ) -> UsingDeclaration<'a> { + UsingDeclaration { span, is_await, declarations } + } + /* ---------- Patterns ---------- */ pub fn binding_pattern( diff --git a/crates/oxc_ast/src/ast_kind.rs b/crates/oxc_ast/src/ast_kind.rs index 27c85086c1ca..559207bbcff8 100644 --- a/crates/oxc_ast/src/ast_kind.rs +++ b/crates/oxc_ast/src/ast_kind.rs @@ -37,6 +37,8 @@ pub enum AstKind<'a> { VariableDeclaration(&'a VariableDeclaration<'a>), VariableDeclarator(&'a VariableDeclarator<'a>), + UsingDeclaration(&'a UsingDeclaration<'a>), + IdentifierName(&'a IdentifierName), IdentifierReference(&'a IdentifierReference), BindingIdentifier(&'a BindingIdentifier), @@ -271,6 +273,8 @@ impl<'a> GetSpan for AstKind<'a> { Self::VariableDeclaration(x) => x.span, Self::VariableDeclarator(x) => x.span, + Self::UsingDeclaration(x) => x.span, + Self::IdentifierName(x) => x.span, Self::IdentifierReference(x) => x.span, Self::BindingIdentifier(x) => x.span, @@ -421,6 +425,8 @@ impl<'a> AstKind<'a> { Self::VariableDeclaration(_) => "VariableDeclaration".into(), Self::VariableDeclarator(_) => "VariableDeclarator".into(), + Self::UsingDeclaration(_) => "UsingDeclaration".into(), + Self::IdentifierName(x) => format!("IdentifierName({})", x.name).into(), Self::IdentifierReference(x) => format!("IdentifierReference({})", x.name).into(), Self::BindingIdentifier(x) => format!("BindingIdentifier({})", x.name).into(), diff --git a/crates/oxc_ast/src/span.rs b/crates/oxc_ast/src/span.rs index 0dbccce50ac3..d1b45d1d9fe3 100644 --- a/crates/oxc_ast/src/span.rs +++ b/crates/oxc_ast/src/span.rs @@ -170,6 +170,7 @@ impl<'a> GetSpan for Declaration<'a> { Self::VariableDeclaration(decl) => decl.span, Self::FunctionDeclaration(decl) => decl.span, Self::ClassDeclaration(decl) => decl.span, + Self::UsingDeclaration(decl) => decl.span, Self::TSTypeAliasDeclaration(decl) => decl.span, Self::TSInterfaceDeclaration(decl) => decl.span, Self::TSEnumDeclaration(decl) => decl.span, @@ -235,6 +236,7 @@ impl<'a> GetSpan for ForStatementInit<'a> { match self { Self::VariableDeclaration(x) => x.span, Self::Expression(x) => x.span(), + Self::UsingDeclaration(x) => x.span, } } } @@ -244,6 +246,7 @@ impl<'a> GetSpan for ForStatementLeft<'a> { match self { Self::VariableDeclaration(x) => x.span, Self::AssignmentTarget(x) => x.span(), + Self::UsingDeclaration(x) => x.span, } } } diff --git a/crates/oxc_ast/src/syntax_directed_operations.rs b/crates/oxc_ast/src/syntax_directed_operations.rs index 6e03c62f006f..ebbc9525bd6d 100644 --- a/crates/oxc_ast/src/syntax_directed_operations.rs +++ b/crates/oxc_ast/src/syntax_directed_operations.rs @@ -95,6 +95,14 @@ impl<'a> BoundNames for VariableDeclaration<'a> { } } +impl<'a> BoundNames for UsingDeclaration<'a> { + fn bound_names(&self, f: &mut F) { + for declarator in &self.declarations { + declarator.id.bound_names(f); + } + } +} + impl<'a> BoundName for Function<'a> { fn bound_name(&self, f: &mut F) { if let Some(ident) = &self.id { diff --git a/crates/oxc_ast/src/visit.rs b/crates/oxc_ast/src/visit.rs index 4ebc71bd3ff2..5acfa15266c6 100644 --- a/crates/oxc_ast/src/visit.rs +++ b/crates/oxc_ast/src/visit.rs @@ -135,6 +135,9 @@ pub trait Visit<'a>: Sized { let kind = AstKind::ForStatementInit(init); self.enter_node(kind); match init { + ForStatementInit::UsingDeclaration(decl) => { + self.visit_using_declaration(decl); + } ForStatementInit::VariableDeclaration(decl) => { self.visit_variable_declaration(decl); } @@ -167,6 +170,9 @@ pub trait Visit<'a>: Sized { self.visit_variable_declaration(decl); } ForStatementLeft::AssignmentTarget(target) => self.visit_assignment_target(target), + ForStatementLeft::UsingDeclaration(decl) => { + self.visit_using_declaration(decl); + } } } @@ -450,6 +456,15 @@ pub trait Visit<'a>: Sized { self.leave_node(kind); } + fn visit_using_declaration(&mut self, decl: &'a UsingDeclaration<'a>) { + let kind = AstKind::UsingDeclaration(decl); + self.enter_node(kind); + for decl in &decl.declarations { + self.visit_variable_declarator(decl); + } + self.leave_node(kind); + } + /* ---------- Expression ---------- */ fn visit_expression(&mut self, expr: &'a Expression<'a>) { @@ -1264,6 +1279,7 @@ pub trait Visit<'a>: Sized { Declaration::VariableDeclaration(decl) => self.visit_variable_declaration(decl), Declaration::FunctionDeclaration(func) => self.visit_function(func), Declaration::ClassDeclaration(class) => self.visit_class(class), + Declaration::UsingDeclaration(decl) => self.visit_using_declaration(decl), Declaration::TSModuleDeclaration(module) => { self.visit_ts_module_declaration(module); } diff --git a/crates/oxc_ast/src/visit_mut.rs b/crates/oxc_ast/src/visit_mut.rs index 8307d210de0b..c4e96f0d6af4 100644 --- a/crates/oxc_ast/src/visit_mut.rs +++ b/crates/oxc_ast/src/visit_mut.rs @@ -97,6 +97,9 @@ pub trait VisitMut<'a, 'b>: Sized { fn visit_for_statement_init(&mut self, init: &'b mut ForStatementInit<'a>) { match init { + ForStatementInit::UsingDeclaration(decl) => { + self.visit_using_declaration(decl); + } ForStatementInit::VariableDeclaration(decl) => { self.visit_variable_declaration(decl); } @@ -122,6 +125,9 @@ pub trait VisitMut<'a, 'b>: Sized { self.visit_variable_declaration(decl); } ForStatementLeft::AssignmentTarget(target) => self.visit_assignment_target(target), + ForStatementLeft::UsingDeclaration(decl) => { + self.visit_using_declaration(decl); + } } } @@ -212,6 +218,12 @@ pub trait VisitMut<'a, 'b>: Sized { } } + fn visit_using_declaration(&mut self, declaration: &'b mut UsingDeclaration<'a>) { + for decl in declaration.declarations.iter_mut() { + self.visit_variable_declarator(decl); + } + } + /* ---------- Function ---------- */ fn visit_function(&mut self, func: &'b mut Function<'a>) { @@ -960,6 +972,7 @@ pub trait VisitMut<'a, 'b>: Sized { Declaration::VariableDeclaration(decl) => self.visit_variable_declaration(decl), Declaration::FunctionDeclaration(func) => self.visit_function(func), Declaration::ClassDeclaration(class) => self.visit_class(class), + Declaration::UsingDeclaration(decl) => self.visit_using_declaration(decl), Declaration::TSModuleDeclaration(module) => { self.visit_ts_module_declaration(module); } diff --git a/crates/oxc_formatter/src/gen.rs b/crates/oxc_formatter/src/gen.rs index 6a02642d3108..c54f2b841ec7 100644 --- a/crates/oxc_formatter/src/gen.rs +++ b/crates/oxc_formatter/src/gen.rs @@ -161,6 +161,7 @@ impl<'a> Gen for ForStatement<'a> { match init { ForStatementInit::Expression(expr) => expr.gen(p), ForStatementInit::VariableDeclaration(var) => var.gen(p), + ForStatementInit::UsingDeclaration(decl) => decl.gen(p), } } @@ -225,6 +226,7 @@ impl<'a> Gen for ForStatementLeft<'a> { match &self { ForStatementLeft::VariableDeclaration(var) => var.gen(p), ForStatementLeft::AssignmentTarget(target) => target.gen(p), + ForStatementLeft::UsingDeclaration(decl) => decl.gen(p), } } } @@ -447,6 +449,10 @@ impl<'a> Gen for Declaration<'a> { declaration.gen(p); p.print_newline(); } + Self::UsingDeclaration(declaration) => { + declaration.gen(p); + p.print_newline(); + } Self::TSTypeAliasDeclaration(_) | Self::TSInterfaceDeclaration(_) | Self::TSEnumDeclaration(_) @@ -467,6 +473,18 @@ impl<'a> Gen for VariableDeclaration<'a> { p.print_list(&self.declarations); } } +impl<'a> Gen for UsingDeclaration<'a> { + fn gen(&self, p: &mut Formatter) { + if self.is_await { + p.print_str(b"await"); + p.print_space(); + } + p.print_str(b"using"); + p.print_space(); + p.print_list(&self.declarations); + p.print_semicolon(); + } +} impl<'a> Gen for VariableDeclarator<'a> { fn gen(&self, p: &mut Formatter) { diff --git a/crates/oxc_minifier/src/printer/gen.rs b/crates/oxc_minifier/src/printer/gen.rs index 4cda073d1c8f..296b800b12eb 100644 --- a/crates/oxc_minifier/src/printer/gen.rs +++ b/crates/oxc_minifier/src/printer/gen.rs @@ -209,6 +209,7 @@ impl<'a> Gen for ForStatement<'a> { if let Some(init) = self.init.as_ref() { let ctx = Context::empty(); match init { + ForStatementInit::UsingDeclaration(decl) => decl.gen(p, ctx), ForStatementInit::Expression(expr) => { expr.gen_expr(p, Precedence::lowest(), ctx); } @@ -267,6 +268,7 @@ impl<'a> Gen for ForOfStatement<'a> { impl<'a> Gen for ForStatementLeft<'a> { fn gen(&self, p: &mut Printer, ctx: Context) { match &self { + ForStatementLeft::UsingDeclaration(var) => var.gen(p, ctx), ForStatementLeft::VariableDeclaration(var) => var.gen(p, ctx), ForStatementLeft::AssignmentTarget(target) => target.gen(p, ctx), } @@ -446,6 +448,9 @@ impl<'a> Gen for Declaration<'a> { Self::ClassDeclaration(declaration) => { declaration.gen(p, ctx); } + Self::UsingDeclaration(declaration) => { + declaration.gen(p, ctx); + } Self::TSEnumDeclaration(_) => {} } } @@ -462,6 +467,19 @@ impl<'a> Gen for VariableDeclaration<'a> { p.print_list(&self.declarations, ctx); } } +impl<'a> Gen for UsingDeclaration<'a> { + fn gen(&self, p: &mut Printer, ctx: Context) { + if self.is_await { + p.print_str(b"await"); + p.print(b' '); + } + p.print_str(b"using"); + p.print(b' '); + + p.print_list(&self.declarations, ctx); + p.print_semicolon(); + } +} impl<'a> Gen for VariableDeclarator<'a> { fn gen(&self, p: &mut Printer, ctx: Context) { diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index a476245b461a..fe660d83c999 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -281,3 +281,13 @@ pub struct ReturnStatementOnlyInFunctionBody(#[label] pub Span); #[error("TS18007: JSX expressions may not use the comma operator.")] #[diagnostic(help("Did you mean to write an array?"))] pub struct JSXExpressionsMayNotUseTheCommaOperator(#[label] pub Span); + +#[derive(Debug, Error, Diagnostic)] +#[error("Line terminator not permitted before using declaration")] +#[diagnostic()] +pub struct LineTerminatorBeforeUsingDeclaration(#[label] pub Span); + +#[derive(Debug, Error, Diagnostic)] +#[error("Await is not allowed in using declarations")] +#[diagnostic()] +pub struct AwaitInUsingDeclaration(#[label] pub Span); diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index 4ef375dc110d..6c57c8405b25 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -42,6 +42,14 @@ impl<'a> Parser<'a> { } } + pub(crate) fn parse_using(&mut self) -> Result> { + let using_decl = self.parse_using_declaration()?; + + self.expect(Kind::Semicolon)?; + + Ok(Statement::Declaration(Declaration::UsingDeclaration(self.ast.alloc(using_decl)))) + } + pub(crate) fn parse_variable_declaration( &mut self, start_span: Span, @@ -102,4 +110,42 @@ impl<'a> Parser<'a> { Ok(self.ast.variable_declarator(self.end_span(span), kind, id, init, definite)) } + + /// UsingDeclaration[In, Yield, Await] : + /// using [no LineTerminator here] [lookahead ≠ await] BindingList[?In, ?Yield, ?Await, ~Pattern] ; + pub(crate) fn parse_using_declaration(&mut self) -> Result> { + let span = self.start_span(); + + let is_await = self.eat(Kind::Await); + + self.expect(Kind::Using)?; + + // `[no LineTerminator here]` + if self.cur_token().is_on_new_line { + self.error(diagnostics::LineTerminatorBeforeUsingDeclaration(self.cur_token().span())); + } + + // [lookahead ≠ await] + if self.cur_kind() == Kind::Await { + self.error(diagnostics::AwaitInUsingDeclaration(self.cur_token().span())); + self.eat(Kind::Await); + } + + // BindingList[?In, ?Yield, ?Await, ~Pattern] + // TODO: work out how to exclude pattern + // TODO: add to context? + let mut declarations: oxc_allocator::Vec<'_, VariableDeclarator<'_>> = self.ast.new_vec(); + loop { + let declaration = self.parse_variable_declarator( + VariableDeclarationContext::new(VariableDeclarationParent::Statement), + VariableDeclarationKind::Var, + )?; + declarations.push(declaration); + if !self.eat(Kind::Comma) { + break; + } + } + + Ok(self.ast.using_declaration(span, declarations, is_await)) + } } diff --git a/crates/oxc_parser/src/lexer/kind.rs b/crates/oxc_parser/src/lexer/kind.rs index c5dbd92545bd..27200beb5d0d 100644 --- a/crates/oxc_parser/src/lexer/kind.rs +++ b/crates/oxc_parser/src/lexer/kind.rs @@ -87,6 +87,7 @@ pub enum Kind { Type, Undefined, Unique, + Using, Unknown, Global, BigInt, @@ -441,6 +442,7 @@ impl Kind { "target" => Target, "typeof" => Typeof, "unique" => Unique, + "using" => Using, "asserts" => Asserts, "boolean" => Boolean, @@ -505,6 +507,7 @@ impl Kind { Finally => "finally", For => "for", Function => "function", + Using => "using", If => "if", Import => "import", In => "in", diff --git a/crates/oxc_parser/src/lexer/mod.rs b/crates/oxc_parser/src/lexer/mod.rs index 5ed7a1e035ca..1631753cbec5 100644 --- a/crates/oxc_parser/src/lexer/mod.rs +++ b/crates/oxc_parser/src/lexer/mod.rs @@ -1788,6 +1788,7 @@ const L_T: ByteHandler = |lexer| match &lexer.identifier_name_handler()[1..] { const L_U: ByteHandler = |lexer| match &lexer.identifier_name_handler()[1..] { "ndefined" => Kind::Undefined, + "sing" => Kind::Using, "nique" => Kind::Unique, "nknown" => Kind::Unknown, _ => Kind::Ident, diff --git a/crates/oxc_type_synthesis/src/statements_and_declarations.rs b/crates/oxc_type_synthesis/src/statements_and_declarations.rs index 54b6cadd7442..8cc6dec2a486 100644 --- a/crates/oxc_type_synthesis/src/statements_and_declarations.rs +++ b/crates/oxc_type_synthesis/src/statements_and_declarations.rs @@ -29,6 +29,7 @@ pub(crate) fn hoist_statements( for (idx, statement) in statements.iter().enumerate() { if let Statement::Declaration(declaration) = statement { match declaration { + ast::Declaration::UsingDeclaration(_) => todo!(), ast::Declaration::VariableDeclaration(_) | ast::Declaration::FunctionDeclaration(_) => {} ast::Declaration::ClassDeclaration(_) => {} @@ -69,6 +70,7 @@ pub(crate) fn hoist_statements( match statement { Statement::ModuleDeclaration(_) => {} Statement::Declaration(declaration) => match declaration { + ast::Declaration::UsingDeclaration(_) => todo!(), ast::Declaration::VariableDeclaration(declaration) => { let is_declare = declaration.modifiers.contains(ast::ModifierKind::Declare); let is_const = matches!(declaration.kind, ast::VariableDeclarationKind::Const); @@ -363,6 +365,8 @@ pub(crate) fn synthesize_declaration( checking_data: &mut CheckingData, ) { match declaration { + ast::Declaration::UsingDeclaration(_) => todo!(), + ast::Declaration::VariableDeclaration(variable_declaration) => { if variable_declaration.modifiers.contains(ast::ModifierKind::Declare) { return; diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 264203bbb80c..b5e06e6b05e8 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,7 +1,7 @@ parser_typescript Summary: -AST Parsed : 5060/5063 (99.94%) -Positive Passed: 5051/5063 (99.76%) -Negative Passed: 996/4761 (20.92%) +AST Parsed : 5137/5142 (99.90%) +Positive Passed: 5129/5142 (99.75%) +Negative Passed: 1014/4824 (21.02%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -78,6 +78,7 @@ Expect Syntax Error: "compiler/argumentsObjectIterator02_ES5.ts" Expect Syntax Error: "compiler/argumentsObjectIterator03_ES5.ts" Expect Syntax Error: "compiler/argumentsPropertyNameInJsMode1.ts" Expect Syntax Error: "compiler/argumentsReferenceInConstructor4_Js.ts" +Expect Syntax Error: "compiler/argumentsReferenceInFunction1_Js.ts" Expect Syntax Error: "compiler/argumentsReferenceInMethod4_Js.ts" Expect Syntax Error: "compiler/argumentsReferenceInObjectLiteral_Js.ts" Expect Syntax Error: "compiler/argumentsSpreadRestIterables.tsx" @@ -252,6 +253,7 @@ Expect Syntax Error: "compiler/checkSuperCallBeforeThisAccessing5.ts" Expect Syntax Error: "compiler/checkSuperCallBeforeThisAccessing8.ts" Expect Syntax Error: "compiler/checkTypePredicateForRedundantProperties.ts" Expect Syntax Error: "compiler/circularAccessorAnnotations.ts" +Expect Syntax Error: "compiler/circularBaseConstraint.ts" Expect Syntax Error: "compiler/circularBaseTypes.ts" Expect Syntax Error: "compiler/circularConstraintYieldsAppropriateError.ts" Expect Syntax Error: "compiler/circularModuleImports.ts" @@ -404,7 +406,9 @@ Expect Syntax Error: "compiler/contextualTypingOfGenericFunctionTypedArguments1. Expect Syntax Error: "compiler/contextualTypingOfLambdaReturnExpression.ts" Expect Syntax Error: "compiler/contextualTypingOfObjectLiterals2.ts" Expect Syntax Error: "compiler/contextualTypingWithFixedTypeParameters1.ts" +Expect Syntax Error: "compiler/contextuallyTypedParametersOptionalInJSDoc.ts" Expect Syntax Error: "compiler/contextuallyTypedParametersWithInitializers.ts" +Expect Syntax Error: "compiler/contextuallyTypedParametersWithQuestionToken.ts" Expect Syntax Error: "compiler/contextuallyTypingRestParameters.ts" Expect Syntax Error: "compiler/continueInIterationStatement4.ts" Expect Syntax Error: "compiler/continueNotInIterationStatement4.ts" @@ -475,6 +479,7 @@ Expect Syntax Error: "compiler/defaultValueInFunctionTypes.ts" Expect Syntax Error: "compiler/definiteAssignmentWithErrorStillStripped.ts" Expect Syntax Error: "compiler/deleteOperator1.ts" Expect Syntax Error: "compiler/deleteReadonly.ts" +Expect Syntax Error: "compiler/deleteReadonlyInStrictNullChecks.ts" Expect Syntax Error: "compiler/derivedClassOverridesPrivateFunction1.ts" Expect Syntax Error: "compiler/derivedClasses.ts" Expect Syntax Error: "compiler/derivedInterfaceCallSignature.ts" @@ -494,6 +499,7 @@ Expect Syntax Error: "compiler/didYouMeanElaborationsForExpressionsWhichCouldBeC Expect Syntax Error: "compiler/didYouMeanStringLiteral.ts" Expect Syntax Error: "compiler/didYouMeanSuggestionErrors.ts" Expect Syntax Error: "compiler/differentTypesWithSameName.ts" +Expect Syntax Error: "compiler/discriminateWithMissingProperty.ts" Expect Syntax Error: "compiler/discriminatedUnionErrorMessage.ts" Expect Syntax Error: "compiler/dissallowSymbolAsWeakType.ts" Expect Syntax Error: "compiler/divergentAccessorsTypes2.ts" @@ -621,6 +627,7 @@ Expect Syntax Error: "compiler/esModuleInteropUsesExportStarWhenDefaultPlusNames Expect Syntax Error: "compiler/evalAfter0.ts" Expect Syntax Error: "compiler/evolvingArrayResolvedAssert.ts" Expect Syntax Error: "compiler/exactSpellingSuggestion.ts" +Expect Syntax Error: "compiler/excessPropertiesInOverloads.ts" Expect Syntax Error: "compiler/excessPropertyCheckIntersectionWithIndexSignature.ts" Expect Syntax Error: "compiler/excessPropertyCheckIntersectionWithRecursiveType.ts" Expect Syntax Error: "compiler/excessPropertyCheckWithEmptyObject.ts" @@ -788,6 +795,7 @@ Expect Syntax Error: "compiler/genericGetter2.ts" Expect Syntax Error: "compiler/genericGetter3.ts" Expect Syntax Error: "compiler/genericImplements.ts" Expect Syntax Error: "compiler/genericIndexTypeHasSensibleErrorMessage.ts" +Expect Syntax Error: "compiler/genericIndexedAccessVarianceComparisonResultCorrect.ts" Expect Syntax Error: "compiler/genericInterfacesWithoutTypeArguments.ts" Expect Syntax Error: "compiler/genericLambaArgWithoutTypeArguments.ts" Expect Syntax Error: "compiler/genericMappedTypeAsClause.ts" @@ -901,12 +909,15 @@ Expect Syntax Error: "compiler/indexSignatureWithInitializer.ts" Expect Syntax Error: "compiler/indexWithUndefinedAndNull.ts" Expect Syntax Error: "compiler/indexWithUndefinedAndNullStrictNullChecks.ts" Expect Syntax Error: "compiler/indexWithoutParamType2.ts" +Expect Syntax Error: "compiler/indexedAccessConstraints.ts" Expect Syntax Error: "compiler/indexedAccessImplicitlyAny.ts" Expect Syntax Error: "compiler/indexedAccessPrivateMemberOfGenericConstraint.ts" Expect Syntax Error: "compiler/indexedAccessRelation.ts" Expect Syntax Error: "compiler/indexedAccessWithFreshObjectLiteral.ts" +Expect Syntax Error: "compiler/indexedAccessWithVariableElement.ts" Expect Syntax Error: "compiler/indexer2A.ts" Expect Syntax Error: "compiler/indexerConstraints.ts" +Expect Syntax Error: "compiler/indirectDiscriminantAndExcessProperty.ts" Expect Syntax Error: "compiler/indirectSelfReference.ts" Expect Syntax Error: "compiler/indirectSelfReferenceGeneric.ts" Expect Syntax Error: "compiler/inexistentPropertyInsideToStringType.ts" @@ -1018,12 +1029,15 @@ Expect Syntax Error: "compiler/jsFileCompilationAmbientVarDeclarationSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationBindDeepExportsAssignment.ts" Expect Syntax Error: "compiler/jsFileCompilationBindReachabilityErrors.ts" Expect Syntax Error: "compiler/jsFileCompilationClassMethodContainingArrowFunction.ts" +Expect Syntax Error: "compiler/jsFileCompilationConstructorOverloadSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationEnumSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationExportAssignmentSyntax.ts" +Expect Syntax Error: "compiler/jsFileCompilationFunctionOverloadSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationHeritageClauseSyntaxOfClass.ts" Expect Syntax Error: "compiler/jsFileCompilationImportEqualsSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationInterfaceSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationLetBeingRenamed.ts" +Expect Syntax Error: "compiler/jsFileCompilationMethodOverloadSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationModuleSyntax.ts" Expect Syntax Error: "compiler/jsFileCompilationNonNullAssertion.ts" Expect Syntax Error: "compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.ts" @@ -1078,9 +1092,11 @@ Expect Syntax Error: "compiler/jsxFactoryIdentifierWithAbsentParameter.ts" Expect Syntax Error: "compiler/jsxFactoryMissingErrorInsideAClass.ts" Expect Syntax Error: "compiler/jsxFactoryQualifiedNameResolutionError.ts" Expect Syntax Error: "compiler/jsxImportSourceNonPragmaComment.tsx" +Expect Syntax Error: "compiler/jsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.tsx" Expect Syntax Error: "compiler/jsxIntrinsicElementsTypeArgumentErrors.tsx" Expect Syntax Error: "compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.tsx" Expect Syntax Error: "compiler/jsxNamespacePrefixIntrinsics.tsx" +Expect Syntax Error: "compiler/jsxSpreadTag.ts" Expect Syntax Error: "compiler/keyofDoesntContainSymbols.ts" Expect Syntax Error: "compiler/keyofIsLiteralContexualType.ts" Expect Syntax Error: "compiler/knockout.ts" @@ -1187,6 +1203,7 @@ Expect Syntax Error: "compiler/multivar.ts" Expect Syntax Error: "compiler/mutuallyRecursiveCallbacks.ts" Expect Syntax Error: "compiler/namedFunctionExpressionCallErrors.ts" Expect Syntax Error: "compiler/namespaceDisambiguationInUnion.ts" +Expect Syntax Error: "compiler/namespaceNotMergedWithFunctionDefaultExport.ts" Expect Syntax Error: "compiler/namespacesDeclaration2.ts" Expect Syntax Error: "compiler/nanEquality.ts" Expect Syntax Error: "compiler/narrowByEquality.ts" @@ -2192,6 +2209,7 @@ Expect Syntax Error: "conformance/enums/enumConstantMemberWithString.ts" Expect Syntax Error: "conformance/enums/enumConstantMemberWithTemplateLiterals.ts" Expect Syntax Error: "conformance/enums/enumConstantMembers.ts" Expect Syntax Error: "conformance/enums/enumMergingErrors.ts" +Expect Syntax Error: "conformance/enums/enumShadowedInfinityNaN.ts" Expect Syntax Error: "conformance/es2017/useObjectValuesAndEntries2.ts" Expect Syntax Error: "conformance/es2017/useObjectValuesAndEntries3.ts" Expect Syntax Error: "conformance/es2017/useSharedArrayBuffer2.ts" @@ -2227,6 +2245,7 @@ Expect Syntax Error: "conformance/es6/Symbols/symbolProperty32.ts" Expect Syntax Error: "conformance/es6/Symbols/symbolProperty33.ts" Expect Syntax Error: "conformance/es6/Symbols/symbolProperty34.ts" Expect Syntax Error: "conformance/es6/Symbols/symbolProperty35.ts" +Expect Syntax Error: "conformance/es6/Symbols/symbolProperty36.ts" Expect Syntax Error: "conformance/es6/Symbols/symbolProperty39.ts" Expect Syntax Error: "conformance/es6/Symbols/symbolProperty42.ts" Expect Syntax Error: "conformance/es6/Symbols/symbolProperty43.ts" @@ -2971,6 +2990,7 @@ Expect Syntax Error: "conformance/jsx/tsxUnionElementType3.tsx" Expect Syntax Error: "conformance/jsx/tsxUnionElementType4.tsx" Expect Syntax Error: "conformance/jsx/tsxUnionElementType6.tsx" Expect Syntax Error: "conformance/jsx/tsxUnionTypeComponent2.tsx" +Expect Syntax Error: "conformance/jsx/unicodeEscapesInJsxtags.tsx" Expect Syntax Error: "conformance/override/override1.ts" Expect Syntax Error: "conformance/override/override11.ts" Expect Syntax Error: "conformance/override/override13.ts" @@ -3316,6 +3336,7 @@ Expect Syntax Error: "conformance/salsa/moduleExportAliasUnknown.ts" Expect Syntax Error: "conformance/salsa/moduleExportsAliasLoop1.ts" Expect Syntax Error: "conformance/salsa/moduleExportsAliasLoop2.ts" Expect Syntax Error: "conformance/salsa/multipleDeclarations.ts" +Expect Syntax Error: "conformance/salsa/plainJSTypeErrors.ts" Expect Syntax Error: "conformance/salsa/propertyAssignmentOnUnresolvedImportedSymbol.ts" Expect Syntax Error: "conformance/salsa/propertyAssignmentUseParentType2.ts" Expect Syntax Error: "conformance/salsa/thisPropertyAssignment.ts" @@ -3347,6 +3368,29 @@ Expect Syntax Error: "conformance/scanner/ecmascript5/scannerS7.6_A4.2_T1.ts" Expect Syntax Error: "conformance/scanner/ecmascript5/scannertest1.ts" Expect Syntax Error: "conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts" Expect Syntax Error: "conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.10.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.12.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.13.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts" +Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts" Expect Syntax Error: "conformance/statements/breakStatements/invalidSwitchBreakStatement.ts" Expect Syntax Error: "conformance/statements/breakStatements/switchBreakStatements.ts" Expect Syntax Error: "conformance/statements/for-inStatements/for-inStatements.ts" @@ -3763,6 +3807,7 @@ Expect Syntax Error: "conformance/types/union/unionTypeWithIndexSignature.ts" Expect Syntax Error: "conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsInJs.ts" Expect Syntax Error: "conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsInJsErrors.ts" Expect Syntax Error: "conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts" +Expect Syntax Error: "conformance/types/uniqueSymbol/uniqueSymbolsPropertyNames.ts" Expect Syntax Error: "conformance/types/unknown/unknownControlFlow.ts" Expect Syntax Error: "conformance/types/unknown/unknownType1.ts" Expect Syntax Error: "conformance/types/unknown/unknownType2.ts" @@ -3871,19 +3916,6 @@ Expect to Parse: "conformance/classes/propertyMemberDeclarations/staticPropertyN 162 │ prototype() {} // ok ╰──── -Expect to Parse: "conformance/es6/for-ofStatements/for-of53.ts" - × Identifier `v` has already been declared - ╭─[conformance/es6/for-ofStatements/for-of53.ts:1:1] - 1 │ //@target: ES6 - 2 │ for (let v of []) { - · ┬ - · ╰── `v` has already been declared here - 3 │ var v; - · ┬ - · ╰── It can not be redeclared here - 4 │ } - ╰──── - Expect to Parse: "conformance/es6/moduleExportsSystem/topLevelVarHoistingCommonJS.ts" × 'with' statements are not allowed ╭─[conformance/es6/moduleExportsSystem/topLevelVarHoistingCommonJS.ts:67:1] @@ -3893,6 +3925,15 @@ Expect to Parse: "conformance/es6/moduleExportsSystem/topLevelVarHoistingCommonJ 69 │ var y = _; ╰──── +Expect to Parse: "conformance/esDecorators/esDecorators-preservesThis.ts" + × Unexpected token + ╭─[conformance/esDecorators/esDecorators-preservesThis.ts:26:1] + 26 │ class C { + 27 │ @super.decorate + · ───── + 28 │ method1() { } + ╰──── + Expect to Parse: "conformance/externalModules/topLevelAwait.2.ts" × Cannot use `await` as an identifier in an async context ╭─[conformance/externalModules/topLevelAwait.2.ts:6:1] @@ -3932,6 +3973,15 @@ Expect to Parse: "conformance/externalModules/topLevelAwait.3.ts" · ───── ╰──── +Expect to Parse: "conformance/parser/ecmascript5/Statements/parserForStatement9.ts" + × Expected `,` but found `in` + ╭─[conformance/parser/ecmascript5/Statements/parserForStatement9.ts:3:1] + 3 │ for (let [x = 'a' in {}] = []; !x; x = !x) console.log(x) + 4 │ for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x) + · ─┬ + · ╰── `,` expected + ╰──── + Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Identifier `orbitol` has already been declared ╭─[conformance/salsa/plainJSRedeclare3.ts:4:1] @@ -8033,6 +8083,12 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" · ─ ╰──── + × Unexpected token + ╭─[compiler/parseUnmatchedTypeAssertion.ts:1:1] + 1 │ @<[[import(obju2c77, + · ─ + ╰──── + × Multiple constructor implementations are not allowed. ╭─[compiler/parserConstructorDeclaration12.ts:1:1] 1 │ class C { @@ -8194,6 +8250,62 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 4 │ ╰──── + × Identifier `v` has already been declared + ╭─[compiler/shadowedFunctionScopedVariablesByBlockScopedOnes.ts:5:1] + 5 │ function test1() { + 6 │ for (let v; ; ) { var v; } + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `v` has already been declared here + 7 │ } + ╰──── + + × Identifier `v` has already been declared + ╭─[compiler/shadowedFunctionScopedVariablesByBlockScopedOnes.ts:8:1] + 8 │ function test2() { + 9 │ for (let v in []) { var v; } + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `v` has already been declared here + 10 │ } + ╰──── + + × Identifier `v` has already been declared + ╭─[compiler/shadowedFunctionScopedVariablesByBlockScopedOnes.ts:11:1] + 11 │ function test3() { + 12 │ for (let v of []) { var v; } + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `v` has already been declared here + 13 │ } + ╰──── + + × Identifier `x` has already been declared + ╭─[compiler/shadowedFunctionScopedVariablesByBlockScopedOnes.ts:15:1] + 15 │ { + 16 │ let x; + · ┬ + · ╰── `x` has already been declared here + 17 │ { + 18 │ var x; + · ┬ + · ╰── It can not be redeclared here + 19 │ } + ╰──── + + × Identifier `x` has already been declared + ╭─[compiler/shadowedFunctionScopedVariablesByBlockScopedOnes.ts:24:1] + 24 │ { + 25 │ var x; + · ┬ + · ╰── `x` has already been declared here + 26 │ } + 27 │ let x; + · ┬ + · ╰── It can not be redeclared here + 28 │ } + ╰──── + × Identifier `x` has already been declared ╭─[compiler/shadowingViaLocalValue.ts:1:1] 1 │ { @@ -9474,6 +9586,15 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" · ╰── A newline is not expected here ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[compiler/typeAliasDeclareKeywordNewlines.ts:3:1] + 3 │ // The following is invalid but should declare a type alias named 'T1': + 4 │ declare type /*unexpected newline*/ + · ─ + 5 │ T1 = null; + ╰──── + help: Try insert a semicolon here + × Cannot assign to 'eval' in strict mode ╭─[compiler/unaryOperatorsInStrictMode.ts:2:1] 2 │ @@ -12487,6 +12608,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 3 │ ({...[]} = {}); ╰──── + × Only a single declaration is allowed in a `for...of` statement + ╭─[conformance/es6/for-ofStatements/for-of-excess-declarations.ts:1:1] + 1 │ // @target: esnext + 2 │ for (const a, { [b]: c} of [1]) { + · ────────────────── + 3 │ + ╰──── + × Missing initializer in const declaration ╭─[conformance/es6/for-ofStatements/for-of2.ts:1:1] 1 │ //@target: ES6 @@ -12518,6 +12647,18 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" · ╰── `v` has already been declared here ╰──── + × Identifier `v` has already been declared + ╭─[conformance/es6/for-ofStatements/for-of53.ts:1:1] + 1 │ //@target: ES6 + 2 │ for (let v of []) { + · ┬ + · ╰── `v` has already been declared here + 3 │ var v; + · ┬ + · ╰── It can not be redeclared here + 4 │ } + ╰──── + × Identifier `v` has already been declared ╭─[conformance/es6/for-ofStatements/for-of54.ts:1:1] 1 │ //@target: ES6 @@ -14911,6 +15052,22 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 3 │ } ╰──── + × Private identifier '#foo' is not allowed outside class bodies + ╭─[conformance/esDecorators/esDecorators-privateFieldAccess.ts:5:1] + 5 │ + 6 │ @dec(x => x.#foo) // error + · ──── + 7 │ class A { + ╰──── + + × Private identifier '#foo' is not allowed outside class bodies + ╭─[conformance/esDecorators/esDecorators-privateFieldAccess.ts:13:1] + 13 │ + 14 │ @dec((x: B) => x.#foo) // error + · ──── + 15 │ class B { + ╰──── + × Cannot assign to this expression ╭─[conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts:5:1] 5 │ class C { @@ -15771,6 +15928,29 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── help: Did you mean to write an array? + × Missing initializer in const declaration + ╭─[conformance/jsx/jsxParsingErrorImmediateSpreadInAttributeValue.tsx:10:1] + 10 │ + 11 │ const X: any + · ─ + 12 │ const a: any + ╰──── + + × Missing initializer in const declaration + ╭─[conformance/jsx/jsxParsingErrorImmediateSpreadInAttributeValue.tsx:11:1] + 11 │ const X: any + 12 │ const a: any + · ─ + 13 │ + ╰──── + + × Unexpected token + ╭─[conformance/jsx/jsxParsingErrorImmediateSpreadInAttributeValue.tsx:13:1] + 13 │ + 14 │ + · ─── + ╰──── + × Unexpected token ╭─[conformance/jsx/jsxUnclosedParserRecovery.ts:13:1] 13 │ var donkey =
@@ -17394,6 +17574,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 2 │ } ╰──── + × Expected `,` but found `in` + ╭─[conformance/parser/ecmascript5/Statements/parserForInStatement8.ts:3:1] + 3 │ for (let [x = 'a' in {}] in { '': 0 }) console.log(x) + 4 │ for (let {x = 'a' in {}} in { '': 0 }) console.log(x) + · ─┬ + · ╰── `,` expected + ╰──── + × Unexpected token ╭─[conformance/parser/ecmascript5/Statements/parserForStatement4.ts:1:1] 1 │ for (a = 1 in b) { @@ -17812,6 +18000,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" · ───── ╰──── + × Expected `,` but found `in` + ╭─[conformance/parser/ecmascript6/Iterators/parserForOfStatement25.ts:5:1] + 5 │ for (let [x = 'a' in {}] of [[]]) console.log(x) + 6 │ for (let {x = 'a' in {}} of [{}]) console.log(x) + · ─┬ + · ╰── `,` expected + ╰──── + × Only a single declaration is allowed in a `for...of` statement ╭─[conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts:1:1] 1 │ //@target: ES6 @@ -18012,6 +18208,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 10 │ #p ╰──── + × Private field 'b' must be declared in an enclosing class + ╭─[conformance/salsa/plainJSGrammarErrors4.ts:9:1] + 9 │ this.#a; // ok + 10 │ this.#b; // error + · ── + 11 │ } + ╰──── + × Identifier `orbitol` has already been declared ╭─[conformance/salsa/plainJSRedeclare.ts:3:1] 3 │ // @filename: plainJSRedeclare.js @@ -18172,6 +18376,73 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" · ──────── ╰──── + × Unexpected token + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.11.ts:5:1] + 5 │ + 6 │ export await using x = null; + · ───── + 7 │ declare await using y: null; + ╰──── + + × Cannot assign to this expression + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts:6:1] + 6 │ { + 7 │ await using [a] = null; + · ─────────────── + 8 │ } + ╰──── + + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts:6:1] + 6 │ { + 7 │ await using {a} = null; + · ─ + 8 │ } + ╰──── + help: Try insert a semicolon here + + × Missing initializer in destructuring declaration + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts:6:1] + 6 │ async function main() { + 7 │ for (await using {} of []) { + · ── + 8 │ } + ╰──── + + × Unexpected token + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.13.ts:5:1] + 5 │ + 6 │ export using x = null; + · ───── + 7 │ declare using y: null; + ╰──── + + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.6.ts:6:1] + 6 │ { + 7 │ using {a} = null; + · ─ + 8 │ } + ╰──── + help: Try insert a semicolon here + + × Unexpected token + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts:5:1] + 5 │ + 6 │ for (using of of []) { + · ─ + 7 │ } + ╰──── + + × Expected `;` but found `{` + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.3.ts:5:1] + 5 │ + 6 │ for (using {} of []) { + · ┬ + · ╰── `;` expected + 7 │ } + ╰──── + × Illegal break statement ╭─[conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts:6:1] 6 │ // naked break not allowed diff --git a/tasks/coverage/test262 b/tasks/coverage/test262 index c4642dd71417..eb613f68914c 160000 --- a/tasks/coverage/test262 +++ b/tasks/coverage/test262 @@ -1 +1 @@ -Subproject commit c4642dd714175b5d27939c920abc6059c9fddb06 +Subproject commit eb613f68914c978e6d6369e5f2415fa8f5fabbfd diff --git a/tasks/coverage/typescript b/tasks/coverage/typescript index 2f34e57ed39b..4b15830a1fb2 160000 --- a/tasks/coverage/typescript +++ b/tasks/coverage/typescript @@ -1 +1 @@ -Subproject commit 2f34e57ed39ba67b4c4b26bbcb6088cf39aa308a +Subproject commit 4b15830a1fb20a89e9c22847e05c3f88a0a31531 From 9f82e9f9ef44b2c013762e082d7cb7040f77b67b Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 15:40:56 +0100 Subject: [PATCH 02/23] wip --- crates/oxc_parser/src/js/expression.rs | 2 +- crates/oxc_parser/src/js/object.rs | 2 +- crates/oxc_parser/src/js/statement.rs | 48 +++++++++++ crates/oxc_parser/src/lexer/kind.rs | 7 +- tasks/coverage/babel | 2 +- tasks/coverage/formatter_test262.snap | 4 +- tasks/coverage/minifier_test262.snap | 4 +- tasks/coverage/parser_test262.snap | 105 ++++++++++++++----------- 8 files changed, 117 insertions(+), 57 deletions(-) diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index f31cf21f669c..a629f6d2897d 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -52,7 +52,7 @@ impl<'a> Parser<'a> { pub(crate) fn parse_identifier_reference(&mut self) -> Result { // allow `await` and `yield`, let semantic analysis report error - if !self.cur_kind().is_identifier_reference(false, false) { + if !self.cur_kind().is_identifier_reference(false, false, false) { return Err(self.unexpected()); } let (span, name) = self.parse_identifier_kind(Kind::Ident); diff --git a/crates/oxc_parser/src/js/object.rs b/crates/oxc_parser/src/js/object.rs index 54ad6d4e2cef..41080f7a8ef7 100644 --- a/crates/oxc_parser/src/js/object.rs +++ b/crates/oxc_parser/src/js/object.rs @@ -48,7 +48,7 @@ impl<'a> Parser<'a> { // GeneratorMethod Kind::Star if class_element_name => self.parse_property_definition_method(), // IdentifierReference - kind if kind.is_identifier_reference(false, false) + kind if kind.is_identifier_reference(false, false, false) // test Kind::Dot to ignore ({ foo.bar: baz }) // see && !matches!( diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index 9b26b6e332ea..83e6faf4577a 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -126,6 +126,39 @@ impl<'a> Parser<'a> { _ if self.ts_enabled() && self.at_start_of_ts_declaration() => { self.parse_ts_declaration_statement(start_span) } + Kind::Await + if self.peek_kind() == Kind::Using + && self.nth_kind(2).is_identifier_reference(false, false, false) => + { + println!("CASE 1"); + self.parse_using() + } + // self.cur_kind().is_identifier_reference(false, false, false) + Kind::Using if self.peek_kind().is_identifier_reference(false, false, false) => { + println!("CASE 2"); + + self.parse_using() + } + // TODO: is this the correct trigger? + // TODO: should the trigger be improved? + // the one after using is not `of` or `in` + // _ if self.ctx.has_await() + // && self.peek_at(Kind::Using) + // && self.nth_kind(2) != Kind::Of => + // { + // self.parse_using() + // } + // _ if self.cur_kind() == Kind::Using && self.peek_kind() != Kind::Of => { + // self.parse_using() + // } + + // _ if (self.ctx.has_await() + // && self.peek_at(Kind::Using) + // && self.nth_at(2, Kind::Ident)) + // || (self.cur_kind() == Kind::Using && self.nth_at(1, Kind::Ident)) => + // { + // self.parse_using() + // } _ => self.parse_expression_or_labeled_statement(), } } @@ -269,6 +302,21 @@ impl<'a> Parser<'a> { return self.parse_for_loop(span, init, r#await); } + if (self.cur_kind() == Kind::Await && self.peek_kind() == Kind::Using) + || (self.cur_kind() == Kind::Using && self.peek_kind() == Kind::Ident) + { + // TODO: rename variables + let x = self.parse_using_declaration()?; + + if matches!(self.cur_kind(), Kind::In | Kind::Of) { + let init = ForStatementLeft::UsingDeclaration(self.ast.alloc(x)); + return self.parse_for_in_or_of_loop(span, r#await, init); + } + + let init = Some(ForStatementInit::UsingDeclaration(self.ast.alloc(x))); + return self.parse_for_loop(span, init, r#await); + } + let is_let_of = self.at(Kind::Let) && self.peek_at(Kind::Of); let is_async_of = self.at(Kind::Async) && !self.cur_token().escaped && self.peek_at(Kind::Of); diff --git a/crates/oxc_parser/src/lexer/kind.rs b/crates/oxc_parser/src/lexer/kind.rs index 27200beb5d0d..3dd0e374b248 100644 --- a/crates/oxc_parser/src/lexer/kind.rs +++ b/crates/oxc_parser/src/lexer/kind.rs @@ -221,8 +221,11 @@ impl Kind { /// [Identifiers](https://tc39.es/ecma262/#sec-identifiers) /// `IdentifierReference` - pub fn is_identifier_reference(self, r#yield: bool, r#await: bool) -> bool { - self.is_identifier() || (!r#yield && self == Yield) || (!r#await && self == Await) + pub fn is_identifier_reference(self, r#yield: bool, r#await: bool, using: bool) -> bool { + self.is_identifier() + || (!r#yield && self == Yield) + || (!r#await && self == Await) + || (!r#using && self == Using) } /// `BindingIdentifier` diff --git a/tasks/coverage/babel b/tasks/coverage/babel index d062d47d57a6..85ae11ee9c8b 160000 --- a/tasks/coverage/babel +++ b/tasks/coverage/babel @@ -1 +1 @@ -Subproject commit d062d47d57a679953144ccf1e60b3efc297e5b43 +Subproject commit 85ae11ee9c8bc219cc465d60dd561872014748c2 diff --git a/tasks/coverage/formatter_test262.snap b/tasks/coverage/formatter_test262.snap index 1372f618fb74..888c47c25751 100644 --- a/tasks/coverage/formatter_test262.snap +++ b/tasks/coverage/formatter_test262.snap @@ -1,3 +1,3 @@ formatter_test262 Summary: -AST Parsed : 44738/44738 (100.00%) -Positive Passed: 44738/44738 (100.00%) +AST Parsed : 45374/45374 (100.00%) +Positive Passed: 45374/45374 (100.00%) diff --git a/tasks/coverage/minifier_test262.snap b/tasks/coverage/minifier_test262.snap index cb57fc58a5a3..f78226b298a1 100644 --- a/tasks/coverage/minifier_test262.snap +++ b/tasks/coverage/minifier_test262.snap @@ -1,3 +1,3 @@ minifier_test262 Summary: -AST Parsed : 44738/44738 (100.00%) -Positive Passed: 44738/44738 (100.00%) +AST Parsed : 45374/45374 (100.00%) +Positive Passed: 45374/45374 (100.00%) diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index 1d85424ac232..67eb6d4a47db 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -1,6 +1,6 @@ parser_test262 Summary: -AST Parsed : 44219/44219 (100.00%) -Positive Passed: 44219/44219 (100.00%) +AST Parsed : 44854/44855 (100.00%) +Positive Passed: 44854/44855 (100.00%) Negative Passed: 3919/3947 (99.29%) Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-01.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-02.js" @@ -30,6 +30,15 @@ Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-fro Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-26.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-27.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-28.js" +Expect to Parse: "language/reserved-words/unreserved-words.js" + × Unexpected token + ╭─[language/reserved-words/unreserved-words.js:106:1] + 106 │ var use = 1; + 107 │ var using = 1; + · ───── + 108 │ var ushort = 1; + ╰──── + × '0'-prefixed octal literals and octal escape sequences are deprecated ╭─[annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict.js:17:1] 17 │ @@ -13006,13 +13015,6 @@ Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-fro · ───────────────── ╰──── - × The keyword 'yield' is reserved - ╭─[language/expressions/dynamic-import/2nd-param-yield-ident-invalid.js:18:1] - 18 │ - 19 │ import('./empty_FIXTURE.js', yield); - · ───── - ╰──── - × Keywords cannot contain escape characters ╭─[language/expressions/dynamic-import/escape-sequence-import.js:34:1] 34 │ @@ -13020,6 +13022,13 @@ Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-fro · ─────────── ╰──── + × The keyword 'yield' is reserved + ╭─[language/expressions/dynamic-import/import-assertions/2nd-param-yield-ident-invalid.js:18:1] + 18 │ + 19 │ import('./empty_FIXTURE.js', yield); + · ───── + ╰──── + × Cannot assign to this expression ╭─[language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-1-update-expression.js:45:1] 45 │ @@ -19355,45 +19364,6 @@ Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-fro · ─ ╰──── - × Identifier `test262_a` has already been declared - ╭─[language/module-code/early-dup-assert-key-export.js:20:1] - 20 │ export * from './import-assertion-3_FIXTURE.js' assert { - 21 │ test262_a: '', - · ────┬──── - · ╰── `test262_a` has already been declared here - 22 │ test262_b: '', - 23 │ 'test262_\u0061': '' - · ────────┬─────── - · ╰── It can not be redeclared here - 24 │ }; - ╰──── - - × Identifier `test262_a` has already been declared - ╭─[language/module-code/early-dup-assert-key-import-nobinding.js:21:1] - 21 │ import './import-assertion-2_FIXTURE.js' assert { - 22 │ test262_a: '', - · ────┬──── - · ╰── `test262_a` has already been declared here - 23 │ test262_b: '', - 24 │ 'test262_\u0061': '' - · ────────┬─────── - · ╰── It can not be redeclared here - 25 │ }; - ╰──── - - × Identifier `test262_a` has already been declared - ╭─[language/module-code/early-dup-assert-key-import-withbinding.js:21:1] - 21 │ import x from './import-assertion-1_FIXTURE.js' assert { - 22 │ test262_a: '', - · ────┬──── - · ╰── `test262_a` has already been declared here - 23 │ test262_b: '', - 24 │ 'test262_\u0061': '' - · ────────┬─────── - · ╰── It can not be redeclared here - 25 │ }; - ╰──── - × Duplicated export 'z' ╭─[language/module-code/early-dup-export-as-star-as.js:17:1] 17 │ var x; @@ -19774,6 +19744,45 @@ Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-fro 22 │ ╰──── + × Identifier `test262_a` has already been declared + ╭─[language/module-code/import-assertions/early-dup-assert-key-export.js:20:1] + 20 │ export * from './import-assertion-3_FIXTURE.js' assert { + 21 │ test262_a: '', + · ────┬──── + · ╰── `test262_a` has already been declared here + 22 │ test262_b: '', + 23 │ 'test262_\u0061': '' + · ────────┬─────── + · ╰── It can not be redeclared here + 24 │ }; + ╰──── + + × Identifier `test262_a` has already been declared + ╭─[language/module-code/import-assertions/early-dup-assert-key-import-nobinding.js:21:1] + 21 │ import './import-assertion-2_FIXTURE.js' assert { + 22 │ test262_a: '', + · ────┬──── + · ╰── `test262_a` has already been declared here + 23 │ test262_b: '', + 24 │ 'test262_\u0061': '' + · ────────┬─────── + · ╰── It can not be redeclared here + 25 │ }; + ╰──── + + × Identifier `test262_a` has already been declared + ╭─[language/module-code/import-assertions/early-dup-assert-key-import-withbinding.js:21:1] + 21 │ import x from './import-assertion-1_FIXTURE.js' assert { + 22 │ test262_a: '', + · ────┬──── + · ╰── `test262_a` has already been declared here + 23 │ test262_b: '', + 24 │ 'test262_\u0061': '' + · ────────┬─────── + · ╰── It can not be redeclared here + 25 │ }; + ╰──── + × Private identifier '#x' is not allowed outside class bodies ╭─[language/module-code/invalid-private-names-call-expression-bad-reference.js:39:1] 39 │ From 81529bc9260d5fc6d5ab9a6ff2319d5f6410115f Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 15:46:11 +0100 Subject: [PATCH 03/23] change order --- crates/oxc_ast/src/span.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/span.rs b/crates/oxc_ast/src/span.rs index d1b45d1d9fe3..bf638710c54d 100644 --- a/crates/oxc_ast/src/span.rs +++ b/crates/oxc_ast/src/span.rs @@ -169,8 +169,8 @@ impl<'a> GetSpan for Declaration<'a> { match self { Self::VariableDeclaration(decl) => decl.span, Self::FunctionDeclaration(decl) => decl.span, - Self::ClassDeclaration(decl) => decl.span, Self::UsingDeclaration(decl) => decl.span, + Self::ClassDeclaration(decl) => decl.span, Self::TSTypeAliasDeclaration(decl) => decl.span, Self::TSInterfaceDeclaration(decl) => decl.span, Self::TSEnumDeclaration(decl) => decl.span, From 80809edb162b7bd61a31fd0df7af6e6f4c07b8e6 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 15:58:41 +0100 Subject: [PATCH 04/23] fix case --- crates/oxc_parser/src/lexer/kind.rs | 2 +- tasks/coverage/parser_test262.snap | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/crates/oxc_parser/src/lexer/kind.rs b/crates/oxc_parser/src/lexer/kind.rs index 3dd0e374b248..01b5475fc501 100644 --- a/crates/oxc_parser/src/lexer/kind.rs +++ b/crates/oxc_parser/src/lexer/kind.rs @@ -230,7 +230,7 @@ impl Kind { /// `BindingIdentifier` pub fn is_binding_identifier(self) -> bool { - self.is_identifier() || matches!(self, Yield | Await) + self.is_identifier() || matches!(self, Yield | Await | Using) } /// `LabelIdentifier` diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index 67eb6d4a47db..3d253700e557 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -1,6 +1,6 @@ parser_test262 Summary: -AST Parsed : 44854/44855 (100.00%) -Positive Passed: 44854/44855 (100.00%) +AST Parsed : 44855/44855 (100.00%) +Positive Passed: 44855/44855 (100.00%) Negative Passed: 3919/3947 (99.29%) Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-01.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-02.js" @@ -30,15 +30,6 @@ Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-fro Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-26.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-27.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-28.js" -Expect to Parse: "language/reserved-words/unreserved-words.js" - × Unexpected token - ╭─[language/reserved-words/unreserved-words.js:106:1] - 106 │ var use = 1; - 107 │ var using = 1; - · ───── - 108 │ var ushort = 1; - ╰──── - × '0'-prefixed octal literals and octal escape sequences are deprecated ╭─[annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict.js:17:1] 17 │ From 08c9ac72a0137b267fb47775498b73ce80013783 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 16:03:17 +0100 Subject: [PATCH 05/23] fix case --- crates/oxc_parser/src/lexer/kind.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/oxc_parser/src/lexer/kind.rs b/crates/oxc_parser/src/lexer/kind.rs index 01b5475fc501..7b5068374c7e 100644 --- a/crates/oxc_parser/src/lexer/kind.rs +++ b/crates/oxc_parser/src/lexer/kind.rs @@ -230,7 +230,7 @@ impl Kind { /// `BindingIdentifier` pub fn is_binding_identifier(self) -> bool { - self.is_identifier() || matches!(self, Yield | Await | Using) + self.is_identifier() || matches!(self, Yield | Await) } /// `LabelIdentifier` @@ -345,7 +345,7 @@ impl Kind { matches!(self, Async | From | Get | Meta | Of | Set | Target | Accessor | Abstract | As | Asserts | Assert | Any | Boolean | Constructor | Declare | Infer | Intrinsic | Is | KeyOf | Module | Namespace | Never | Out | Readonly | Require | Number | Object | Satisfies | String - | Symbol | Type | Undefined | Unique | Unknown | Global | BigInt | Override) + | Symbol | Type | Undefined | Unique | Unknown | Using | Global | BigInt | Override) } #[rustfmt::skip] From c79681d64ecf01475f40cd6568d42edc394b1c72 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 16:10:04 +0100 Subject: [PATCH 06/23] fix fn --- crates/oxc_parser/src/js/expression.rs | 2 +- crates/oxc_parser/src/js/object.rs | 2 +- crates/oxc_parser/src/js/statement.rs | 4 ++-- crates/oxc_parser/src/lexer/kind.rs | 7 ++----- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index a629f6d2897d..f31cf21f669c 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -52,7 +52,7 @@ impl<'a> Parser<'a> { pub(crate) fn parse_identifier_reference(&mut self) -> Result { // allow `await` and `yield`, let semantic analysis report error - if !self.cur_kind().is_identifier_reference(false, false, false) { + if !self.cur_kind().is_identifier_reference(false, false) { return Err(self.unexpected()); } let (span, name) = self.parse_identifier_kind(Kind::Ident); diff --git a/crates/oxc_parser/src/js/object.rs b/crates/oxc_parser/src/js/object.rs index 41080f7a8ef7..54ad6d4e2cef 100644 --- a/crates/oxc_parser/src/js/object.rs +++ b/crates/oxc_parser/src/js/object.rs @@ -48,7 +48,7 @@ impl<'a> Parser<'a> { // GeneratorMethod Kind::Star if class_element_name => self.parse_property_definition_method(), // IdentifierReference - kind if kind.is_identifier_reference(false, false, false) + kind if kind.is_identifier_reference(false, false) // test Kind::Dot to ignore ({ foo.bar: baz }) // see && !matches!( diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index 83e6faf4577a..2362ac03fc25 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -128,13 +128,13 @@ impl<'a> Parser<'a> { } Kind::Await if self.peek_kind() == Kind::Using - && self.nth_kind(2).is_identifier_reference(false, false, false) => + && self.nth_kind(2).is_identifier_reference(false, false) => { println!("CASE 1"); self.parse_using() } // self.cur_kind().is_identifier_reference(false, false, false) - Kind::Using if self.peek_kind().is_identifier_reference(false, false, false) => { + Kind::Using if self.peek_kind().is_identifier_reference(false, false) => { println!("CASE 2"); self.parse_using() diff --git a/crates/oxc_parser/src/lexer/kind.rs b/crates/oxc_parser/src/lexer/kind.rs index 7b5068374c7e..89e2aed7eb0b 100644 --- a/crates/oxc_parser/src/lexer/kind.rs +++ b/crates/oxc_parser/src/lexer/kind.rs @@ -221,11 +221,8 @@ impl Kind { /// [Identifiers](https://tc39.es/ecma262/#sec-identifiers) /// `IdentifierReference` - pub fn is_identifier_reference(self, r#yield: bool, r#await: bool, using: bool) -> bool { - self.is_identifier() - || (!r#yield && self == Yield) - || (!r#await && self == Await) - || (!r#using && self == Using) + pub fn is_identifier_reference(self, r#yield: bool, r#await: bool) -> bool { + self.is_identifier() || (!r#yield && self == Yield) || (!r#await && self == Await) } /// `BindingIdentifier` From 38ca761bdb436cec5b8c8494f7eb73ccecfdcb74 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 16:12:19 +0100 Subject: [PATCH 07/23] fix case --- crates/oxc_parser/src/js/statement.rs | 37 ++++----------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index 2362ac03fc25..e1b3441985f0 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -122,43 +122,16 @@ impl<'a> Parser<'a> { self.parse_variable_statement(stmt_ctx) } Kind::Let if !self.cur_token().escaped => self.parse_let(stmt_ctx), - _ if self.at_function_with_async() => self.parse_function_declaration(stmt_ctx), - _ if self.ts_enabled() && self.at_start_of_ts_declaration() => { - self.parse_ts_declaration_statement(start_span) - } Kind::Await - if self.peek_kind() == Kind::Using - && self.nth_kind(2).is_identifier_reference(false, false) => + if self.peek_kind() == Kind::Using && self.nth_kind(2).is_binding_identifier() => { - println!("CASE 1"); self.parse_using() } - // self.cur_kind().is_identifier_reference(false, false, false) - Kind::Using if self.peek_kind().is_identifier_reference(false, false) => { - println!("CASE 2"); - - self.parse_using() + Kind::Using if self.peek_kind().is_binding_identifier() => self.parse_using(), + _ if self.at_function_with_async() => self.parse_function_declaration(stmt_ctx), + _ if self.ts_enabled() && self.at_start_of_ts_declaration() => { + self.parse_ts_declaration_statement(start_span) } - // TODO: is this the correct trigger? - // TODO: should the trigger be improved? - // the one after using is not `of` or `in` - // _ if self.ctx.has_await() - // && self.peek_at(Kind::Using) - // && self.nth_kind(2) != Kind::Of => - // { - // self.parse_using() - // } - // _ if self.cur_kind() == Kind::Using && self.peek_kind() != Kind::Of => { - // self.parse_using() - // } - - // _ if (self.ctx.has_await() - // && self.peek_at(Kind::Using) - // && self.nth_at(2, Kind::Ident)) - // || (self.cur_kind() == Kind::Using && self.nth_at(1, Kind::Ident)) => - // { - // self.parse_using() - // } _ => self.parse_expression_or_labeled_statement(), } } From dd68a6d026e94e6d9cad51fcf47e188780995443 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 29 Aug 2023 16:15:56 +0100 Subject: [PATCH 08/23] order --- crates/oxc_ast/src/visit_mut.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/oxc_ast/src/visit_mut.rs b/crates/oxc_ast/src/visit_mut.rs index c4e96f0d6af4..96d9099bd626 100644 --- a/crates/oxc_ast/src/visit_mut.rs +++ b/crates/oxc_ast/src/visit_mut.rs @@ -97,13 +97,13 @@ pub trait VisitMut<'a, 'b>: Sized { fn visit_for_statement_init(&mut self, init: &'b mut ForStatementInit<'a>) { match init { - ForStatementInit::UsingDeclaration(decl) => { - self.visit_using_declaration(decl); - } ForStatementInit::VariableDeclaration(decl) => { self.visit_variable_declaration(decl); } ForStatementInit::Expression(expr) => self.visit_expression(expr), + ForStatementInit::UsingDeclaration(decl) => { + self.visit_using_declaration(decl); + } } } From 354aec71c18f817bc92af565300f2f3263a014d6 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Fri, 15 Sep 2023 23:21:00 +0100 Subject: [PATCH 09/23] just sync --- .gitignore | 2 +- tasks/coverage/babel | 2 +- tasks/coverage/formatter_babel.snap | 4 +- tasks/coverage/formatter_test262.snap | 4 +- tasks/coverage/parser_babel.snap | 167 ++++++++++++-------------- tasks/coverage/parser_test262.snap | 55 ++++----- tasks/coverage/parser_typescript.snap | 110 +++++++++-------- tasks/coverage/test262 | 2 +- tasks/coverage/typescript | 2 +- 9 files changed, 166 insertions(+), 182 deletions(-) diff --git a/.gitignore b/.gitignore index 2fb49770b582..3f3db603f48e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ crates/oxc_napi/*.node /*.tsx # MacOS -.DS_Store \ No newline at end of file +.DS_Store diff --git a/tasks/coverage/babel b/tasks/coverage/babel index 85ae11ee9c8b..feef4b1c2f46 160000 --- a/tasks/coverage/babel +++ b/tasks/coverage/babel @@ -1 +1 @@ -Subproject commit 85ae11ee9c8bc219cc465d60dd561872014748c2 +Subproject commit feef4b1c2f4666e91d612273cd7bfdc2ca3df5b6 diff --git a/tasks/coverage/formatter_babel.snap b/tasks/coverage/formatter_babel.snap index d0fe180100f3..1ca9e03396f2 100644 --- a/tasks/coverage/formatter_babel.snap +++ b/tasks/coverage/formatter_babel.snap @@ -1,6 +1,6 @@ formatter_babel Summary: -AST Parsed : 2078/2078 (100.00%) -Positive Passed: 2055/2078 (98.89%) +AST Parsed : 2083/2083 (100.00%) +Positive Passed: 2060/2083 (98.90%) Expect to Parse: "typescript/cast/nested-parenthesized-assert-and-assign/input.ts" Expect to Parse: "typescript/class/abstract/input.ts" Expect to Parse: "typescript/class/declare/input.ts" diff --git a/tasks/coverage/formatter_test262.snap b/tasks/coverage/formatter_test262.snap index 888c47c25751..2412ef4542a7 100644 --- a/tasks/coverage/formatter_test262.snap +++ b/tasks/coverage/formatter_test262.snap @@ -1,3 +1,3 @@ formatter_test262 Summary: -AST Parsed : 45374/45374 (100.00%) -Positive Passed: 45374/45374 (100.00%) +AST Parsed : 45471/45471 (100.00%) +Positive Passed: 45471/45471 (100.00%) diff --git a/tasks/coverage/parser_babel.snap b/tasks/coverage/parser_babel.snap index b69ec2c9407c..7b0b364ec148 100644 --- a/tasks/coverage/parser_babel.snap +++ b/tasks/coverage/parser_babel.snap @@ -1,7 +1,7 @@ parser_babel Summary: -AST Parsed : 2072/2078 (99.71%) -Positive Passed: 2069/2078 (99.57%) -Negative Passed: 1342/1507 (89.05%) +AST Parsed : 2077/2083 (99.71%) +Positive Passed: 2074/2083 (99.57%) +Negative Passed: 1342/1495 (89.77%) Expect Syntax Error: "annex-b/disabled/1.1-html-comments-close/input.js" Expect Syntax Error: "annex-b/disabled/3.1-sloppy-labeled-functions/input.js" Expect Syntax Error: "annex-b/disabled/3.1-sloppy-labeled-functions-if-body/input.js" @@ -21,11 +21,9 @@ Expect Syntax Error: "es2015/class-methods/direct-super-in-object-method/input.j Expect Syntax Error: "es2015/destructuring/error-operator-for-default/input.js" Expect Syntax Error: "es2015/for-of/invalid-let-as-identifier/input.js" Expect Syntax Error: "es2015/object/disallow-duplicate-method-params/input.js" -Expect Syntax Error: "es2015/uncategorised/.191/input.js" -Expect Syntax Error: "es2015/uncategorised/.335/input.js" -Expect Syntax Error: "es2015/uncategorised/.343/input.js" Expect Syntax Error: "es2015/uncategorised/220/input.js" Expect Syntax Error: "es2015/uncategorised/297/input.js" +Expect Syntax Error: "es2015/uncategorised/335/input.js" Expect Syntax Error: "es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/input.js" Expect Syntax Error: "es2017/trailing-function-commas/7/input.js" Expect Syntax Error: "es2018/object-rest-spread/24/input.js" @@ -36,19 +34,9 @@ Expect Syntax Error: "es2018/object-rest-spread/no-pattern-in-rest/input.js" Expect Syntax Error: "es2018/object-rest-spread/no-pattern-in-rest-with-ts/input.js" Expect Syntax Error: "es2020/dynamic-import/invalid-trailing-comma/input.js" Expect Syntax Error: "esprima/es2015-arrow-function/invalid-param-strict-mode/input.js" -Expect Syntax Error: "esprima/es2015-generator/.generator-parameter-binding-property-reserved/input.js" -Expect Syntax Error: "esprima/es2015-identifier/.invalid_function_wait/input.js" -Expect Syntax Error: "esprima/expression-primary-literal-regular-expression/.migrated_0005/input.js" -Expect Syntax Error: "esprima/expression-primary-literal-regular-expression/.migrated_0006/input.js" -Expect Syntax Error: "esprima/expression-primary-literal-regular-expression/.u-flag-invalid-range-4-hex/input.js" -Expect Syntax Error: "esprima/expression-primary-literal-regular-expression/.u-flag-invalid-range-var-hex/input.js" -Expect Syntax Error: "esprima/invalid-syntax/.GH-1106-09/input.js" -Expect Syntax Error: "esprima/invalid-syntax/.migrated_0035/input.js" +Expect Syntax Error: "esprima/es2015-generator/generator-parameter-binding-property-reserved/input.js" Expect Syntax Error: "esprima/invalid-syntax/migrated_0101/input.js" Expect Syntax Error: "esprima/rest-parameter/invalid-setter-rest/input.js" -Expect Syntax Error: "esprima/statement-if/.migrated_0003/input.js" -Expect Syntax Error: "esprima/statement-iteration/.migrated_0021/input.js" -Expect Syntax Error: "esprima/statement-iteration/.pattern-in-for-in/input.js" Expect Syntax Error: "typescript/arrow-function/async-rest-optional-parameter/input.ts" Expect Syntax Error: "typescript/cast/satisfies-const-error/input.ts" Expect Syntax Error: "typescript/cast/unparenthesized-assert-and-assign/input.ts" @@ -599,12 +587,24 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ──────── ╰──── + × A 'get' accessor must not have any formal parameters. + ╭─[core/object/invalid-getter-param/input.js:1:1] + 1 │ ({ get prop(x) {} }) + · ─── + ╰──── + × A 'set' accessor must have exactly one parameter. - ╭─[core/object/invalid-setter/input.js:1:1] + ╭─[core/object/invalid-setter-no-param/input.js:1:1] 1 │ ({ set x(){} }) · ── ╰──── + × A 'set' accessor must have exactly one parameter. + ╭─[core/object/invalid-setter-two-params/input.js:1:1] + 1 │ ({ set prop(x, y) {} }) + · ────── + ╰──── + × Expected `(` but found `await` ╭─[core/opts/allowAwaitOutsideFunction-false/input.js:1:1] 1 │ for await (const i of imports) {} @@ -931,24 +931,6 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── help: In strict mode code, functions can only be declared at top level or inside a block - × A 'get' accessor must not have any formal parameters. - ╭─[core/uncategorised/.542/input.js:1:1] - 1 │ ({ get prop(x) {} }) - · ─── - ╰──── - - × A 'set' accessor must have exactly one parameter. - ╭─[core/uncategorised/.543/input.js:1:1] - 1 │ ({ set prop() {} }) - · ── - ╰──── - - × A 'set' accessor must have exactly one parameter. - ╭─[core/uncategorised/.544/input.js:1:1] - 1 │ ({ set prop(x, y) {} }) - · ────── - ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[core/uncategorised/108/input.js:1:1] 1 │ var x = /[P QR]/\u0067 @@ -3365,24 +3347,6 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" 3 │ `; ╰──── - × A 'yield' expression is only allowed in a generator body. - ╭─[es2015/uncategorised/.260/input.js:1:1] - 1 │ (function() { "use strict"; f(yield v) }) - · ───── - ╰──── - - × A 'get' accessor must not have any formal parameters. - ╭─[es2015/uncategorised/.345/input.js:1:1] - 1 │ class A { get prop(x) {} } - · ─── - ╰──── - - × A 'set' accessor must have exactly one parameter. - ╭─[es2015/uncategorised/.346/input.js:1:1] - 1 │ class A { set prop() {} } - · ── - ╰──── - × for-of loop variable declaration may not have an initializer ╭─[es2015/uncategorised/109/input.js:1:1] 1 │ for (var x = 42 of list) process(x); @@ -3756,6 +3720,12 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ╰── `]` expected ╰──── + × A 'yield' expression is only allowed in a generator body. + ╭─[es2015/uncategorised/260/input.js:1:1] + 1 │ (function() { "use strict"; f(yield v) }) + · ───── + ╰──── + × Expected `(` but found `**` ╭─[es2015/uncategorised/261/input.js:1:1] 1 │ var obj = { *test** } @@ -4020,6 +3990,18 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ───── ╰──── + × A 'get' accessor must not have any formal parameters. + ╭─[es2015/uncategorised/345/input.js:1:1] + 1 │ class A { get prop(x) {} } + · ─── + ╰──── + + × A 'set' accessor must have exactly one parameter. + ╭─[es2015/uncategorised/346/input.js:1:1] + 1 │ class A { set prop() {} } + · ── + ╰──── + × A 'set' accessor must have exactly one parameter. ╭─[es2015/uncategorised/347/input.js:1:1] 1 │ class A { set prop(x, y) {} } @@ -6737,12 +6719,6 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ╰── `x` has already been declared here ╰──── - × Unexpected trailing comma after rest element - ╭─[esprima/es2015-array-binding-pattern/.invalid-elision-after-rest/input.js:1:1] - 1 │ ([a,...b,])=>0; - · ─ - ╰──── - × Identifier `b` has already been declared ╭─[esprima/es2015-array-binding-pattern/invalid-dup-param/input.js:1:1] 1 │ ([a,[b],...b])=>0; @@ -6751,6 +6727,12 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ╰── `b` has already been declared here ╰──── + × Unexpected trailing comma after rest element + ╭─[esprima/es2015-array-binding-pattern/invalid-elision-after-rest/input.js:1:1] + 1 │ ([a,...b,])=>0; + · ─ + ╰──── + × Identifier `a` has already been declared ╭─[esprima/es2015-array-pattern/dupe-param-1/input.js:1:1] 1 │ "use strict"; @@ -6881,7 +6863,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── × Cannot assign to 'eval' in strict mode - ╭─[esprima/es2015-class/.migrated_0026/input.js:1:1] + ╭─[esprima/es2015-class/invalid-eval-in-class-method-params/input.js:1:1] 1 │ class A {a(eval){}} · ──── ╰──── @@ -7088,19 +7070,6 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── - × Invalid Unicode escape sequence - ╭─[esprima/es2015-identifier/.invalid_lone_surrogate/input.js:1:1] - 1 │ \uD800! - · ───── - ╰──── - - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[esprima/es2015-identifier/.invalid_lone_surrogate/input.js:1:1] - 1 │ \uD800! - · ▲ - ╰──── - help: Try insert a semicolon here - × Invalid Unicode escape sequence ╭─[esprima/es2015-identifier/invalid_escaped_surrogate_pairs/input.js:1:1] 1 │ var \uD83B\uDE00 @@ -7119,6 +7088,19 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── + × Invalid Unicode escape sequence + ╭─[esprima/es2015-identifier/invalid_lone_surrogate/input.js:1:1] + 1 │ \uD800! + · ───── + ╰──── + + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[esprima/es2015-identifier/invalid_lone_surrogate/input.js:1:1] + 1 │ \uD800! + · ▲ + ╰──── + help: Try insert a semicolon here + × Cannot use export statement outside a module ╭─[esprima/es2015-identifier/invalid_var_await/input.js:1:1] 1 │ export var await; @@ -7337,7 +7319,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" ╰──── × 'super' can only be used with function calls or in property accesses - ╭─[esprima/es2015-super-property/.invalid_super_access/input.js:2:1] + ╭─[esprima/es2015-super-property/invalid_super_access/input.js:2:1] 2 │ constructor() { 3 │ (super)(); · ───── @@ -7346,7 +7328,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" help: replace with `super()` or `super.prop` or `super[prop]` × 'super' can only be used with function calls or in property accesses - ╭─[esprima/es2015-super-property/.invalid_super_id/input.js:1:1] + ╭─[esprima/es2015-super-property/invalid_super_id/input.js:1:1] 1 │ class A { 2 │ foo() { new super + 3 } · ───── @@ -7356,7 +7338,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" × Super calls are not permitted outside constructors or in nested functions inside constructors. │ - ╭─[esprima/es2015-super-property/.invalid_super_id/input.js:1:1] + ╭─[esprima/es2015-super-property/invalid_super_id/input.js:1:1] 1 │ class A { 2 │ foo() { new super + 3 } · ───────── @@ -7370,18 +7352,6 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─────── ╰──── - × Bad escape sequence in untagged template literal - ╭─[esprima/es2015-template-literals/.octal-literal/input.js:1:1] - 1 │ `\00`; - · ─── - ╰──── - - × Bad escape sequence in untagged template literal - ╭─[esprima/es2015-template-literals/.strict-octal-literal/input.js:1:1] - 1 │ 'use strict'; `\00`; - · ─── - ╰──── - × Expected `(` but found `${}` ╭─[esprima/es2015-template-literals/after-switch/input.js:1:1] 1 │ switch `test` @@ -7395,6 +7365,18 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ── ╰──── + × Bad escape sequence in untagged template literal + ╭─[esprima/es2015-template-literals/invalid-octal-literal/input.js:1:1] + 1 │ `\00`; + · ─── + ╰──── + + × Bad escape sequence in untagged template literal + ╭─[esprima/es2015-template-literals/invalid-strict-octal-literal/input.js:1:1] + 1 │ 'use strict'; `\00`; + · ─── + ╰──── + × Unterminated string ╭─[esprima/es2015-template-literals/unclosed/input.js:1:1] 1 │ `test @@ -7660,6 +7642,13 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ───── ╰──── + × Invalid escape sequence + ╭─[esprima/invalid-syntax/GH-1106-09/input.js:1:1] + 1 │ "\9"; + · ──── + ╰──── + help: \8 and \9 are not allowed in strict mode + × Expected `}` but found `EOF` ╭─[esprima/invalid-syntax/migrated_0000/input.js:1:1] 1 │ { diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index 3d253700e557..f6a3f13cd5e8 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -1,6 +1,6 @@ parser_test262 Summary: -AST Parsed : 44855/44855 (100.00%) -Positive Passed: 44855/44855 (100.00%) +AST Parsed : 44947/44947 (100.00%) +Positive Passed: 44947/44947 (100.00%) Negative Passed: 3919/3947 (99.29%) Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-01.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-02.js" @@ -19735,43 +19735,40 @@ Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-fro 22 │ ╰──── - × Identifier `test262_a` has already been declared + × Identifier `type` has already been declared ╭─[language/module-code/import-assertions/early-dup-assert-key-export.js:20:1] 20 │ export * from './import-assertion-3_FIXTURE.js' assert { - 21 │ test262_a: '', - · ────┬──── - · ╰── `test262_a` has already been declared here - 22 │ test262_b: '', - 23 │ 'test262_\u0061': '' - · ────────┬─────── - · ╰── It can not be redeclared here - 24 │ }; + 21 │ type: 'json', + · ──┬─ + · ╰── `type` has already been declared here + 22 │ 'typ\u0065': '' + · ─────┬───── + · ╰── It can not be redeclared here + 23 │ }; ╰──── - × Identifier `test262_a` has already been declared + × Identifier `type` has already been declared ╭─[language/module-code/import-assertions/early-dup-assert-key-import-nobinding.js:21:1] 21 │ import './import-assertion-2_FIXTURE.js' assert { - 22 │ test262_a: '', - · ────┬──── - · ╰── `test262_a` has already been declared here - 23 │ test262_b: '', - 24 │ 'test262_\u0061': '' - · ────────┬─────── - · ╰── It can not be redeclared here - 25 │ }; + 22 │ type: 'json', + · ──┬─ + · ╰── `type` has already been declared here + 23 │ 'typ\u0065': '' + · ─────┬───── + · ╰── It can not be redeclared here + 24 │ }; ╰──── - × Identifier `test262_a` has already been declared + × Identifier `type` has already been declared ╭─[language/module-code/import-assertions/early-dup-assert-key-import-withbinding.js:21:1] 21 │ import x from './import-assertion-1_FIXTURE.js' assert { - 22 │ test262_a: '', - · ────┬──── - · ╰── `test262_a` has already been declared here - 23 │ test262_b: '', - 24 │ 'test262_\u0061': '' - · ────────┬─────── - · ╰── It can not be redeclared here - 25 │ }; + 22 │ type: 'json', + · ──┬─ + · ╰── `type` has already been declared here + 23 │ 'typ\u0065': '' + · ─────┬───── + · ╰── It can not be redeclared here + 24 │ }; ╰──── × Private identifier '#x' is not allowed outside class bodies diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index b5e06e6b05e8..47e755a408fb 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,7 +1,7 @@ parser_typescript Summary: -AST Parsed : 5137/5142 (99.90%) -Positive Passed: 5129/5142 (99.75%) -Negative Passed: 1014/4824 (21.02%) +AST Parsed : 5158/5162 (99.92%) +Positive Passed: 5150/5162 (99.77%) +Negative Passed: 1014/4831 (20.99%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -275,6 +275,8 @@ Expect Syntax Error: "compiler/classExtendsInterfaceThatExtendsClassWithPrivates Expect Syntax Error: "compiler/classExtendsInterface_not.ts" Expect Syntax Error: "compiler/classExtendsMultipleBaseClasses.ts" Expect Syntax Error: "compiler/classExtendsNull.ts" +Expect Syntax Error: "compiler/classExtendsNull2.ts" +Expect Syntax Error: "compiler/classExtendsNull3.ts" Expect Syntax Error: "compiler/classImplementsClass2.ts" Expect Syntax Error: "compiler/classImplementsClass4.ts" Expect Syntax Error: "compiler/classImplementsClass5.ts" @@ -470,6 +472,7 @@ Expect Syntax Error: "compiler/deepKeysIndexing.ts" Expect Syntax Error: "compiler/deeplyNestedAssignabilityErrorsCombined.ts" Expect Syntax Error: "compiler/deeplyNestedAssignabilityIssue.ts" Expect Syntax Error: "compiler/deeplyNestedCheck.ts" +Expect Syntax Error: "compiler/deeplyNestedMappedTypes.ts" Expect Syntax Error: "compiler/defaultArgsInFunctionExpressions.ts" Expect Syntax Error: "compiler/defaultArgsInOverloads.ts" Expect Syntax Error: "compiler/defaultBestCommonTypesHaveDecls.ts" @@ -506,6 +509,7 @@ Expect Syntax Error: "compiler/divergentAccessorsTypes2.ts" Expect Syntax Error: "compiler/divergentAccessorsTypes4.ts" Expect Syntax Error: "compiler/divergentAccessorsTypes5.ts" Expect Syntax Error: "compiler/divergentAccessorsTypes6.ts" +Expect Syntax Error: "compiler/divergentAccessorsTypes8.ts" Expect Syntax Error: "compiler/divergentAccessorsVisibility1.ts" Expect Syntax Error: "compiler/doNotElaborateAssignabilityToTypeParameters.ts" Expect Syntax Error: "compiler/doYouNeedToChangeYourTargetLibraryES2015.ts" @@ -2156,6 +2160,7 @@ Expect Syntax Error: "conformance/classes/staticIndexSignature/staticIndexSignat Expect Syntax Error: "conformance/classes/staticIndexSignature/staticIndexSignature3.ts" Expect Syntax Error: "conformance/classes/staticIndexSignature/staticIndexSignature7.ts" Expect Syntax Error: "conformance/constEnums/constEnum2.ts" +Expect Syntax Error: "conformance/constEnums/constEnumNoObjectPrototypePropertyAccess.ts" Expect Syntax Error: "conformance/constEnums/constEnumPropertyAccess1.ts" Expect Syntax Error: "conformance/constEnums/constEnumPropertyAccess2.ts" Expect Syntax Error: "conformance/controlFlow/controlFlowAliasing.ts" @@ -3213,6 +3218,7 @@ Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserExpression Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserForInStatement1.d.ts" Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserForInStatement4.ts" Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserForInStatement5.ts" +Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserForInStatement8.ts" Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserForStatement1.d.ts" Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserForStatement2.ts" Expect Syntax Error: "conformance/parser/ecmascript5/Statements/parserForStatement3.ts" @@ -3319,6 +3325,7 @@ Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatem Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatement15.ts" Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatement16.ts" Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts" +Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatement25.ts" Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts" Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts" Expect Syntax Error: "conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts" @@ -3869,51 +3876,51 @@ Expect to Parse: "conformance/async/es6/asyncWithVarShadowing_es6.ts" Expect to Parse: "conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts" × Classes may not have a static property named prototype - ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:27:1] - 27 │ class StaticPrototype { - 28 │ static prototype: number; // always an error + ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:55:1] + 55 │ class StaticPrototype { + 56 │ static prototype: number; // always an error · ───────── - 29 │ prototype: string; // ok + 57 │ prototype: string; // ok ╰──── × Classes may not have a static property named prototype - ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:32:1] - 32 │ class StaticPrototypeFn { - 33 │ static prototype() {} // always an error + ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:65:1] + 65 │ class StaticPrototypeFn { + 66 │ static prototype() {} // always an error · ───────── - 34 │ prototype() {} // ok + 67 │ prototype() {} // ok ╰──── × Classes may not have a static property named prototype - ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:86:1] - 86 │ var StaticPrototype_Anonymous = class { - 87 │ static prototype: number; // always an error - · ───────── - 88 │ prototype: string; // ok - ╰──── + ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:163:1] + 163 │ var StaticPrototype_Anonymous = class { + 164 │ static prototype: number; // always an error + · ───────── + 165 │ prototype: string; // ok + ╰──── × Classes may not have a static property named prototype - ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:91:1] - 91 │ var StaticPrototypeFn_Anonymous = class { - 92 │ static prototype() {} // always an error - · ───────── - 93 │ prototype() {} // ok - ╰──── + ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:173:1] + 173 │ var StaticPrototypeFn_Anonymous = class { + 174 │ static prototype() {} // always an error + · ───────── + 175 │ prototype() {} // ok + ╰──── × Classes may not have a static property named prototype - ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:153:1] - 153 │ export default class StaticPrototype { - 154 │ static prototype: number; // always an error + ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:280:1] + 280 │ export default class StaticPrototype { + 281 │ static prototype: number; // always an error · ───────── - 155 │ prototype: string; // ok + 282 │ prototype: string; // ok ╰──── × Classes may not have a static property named prototype - ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:160:1] - 160 │ export default class StaticPrototypeFn { - 161 │ static prototype() {} // always an error + ╭─[conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts:292:1] + 292 │ export default class StaticPrototypeFn { + 293 │ static prototype() {} // always an error · ───────── - 162 │ prototype() {} // ok + 294 │ prototype() {} // ok ╰──── Expect to Parse: "conformance/es6/moduleExportsSystem/topLevelVarHoistingCommonJS.ts" @@ -3973,15 +3980,6 @@ Expect to Parse: "conformance/externalModules/topLevelAwait.3.ts" · ───── ╰──── -Expect to Parse: "conformance/parser/ecmascript5/Statements/parserForStatement9.ts" - × Expected `,` but found `in` - ╭─[conformance/parser/ecmascript5/Statements/parserForStatement9.ts:3:1] - 3 │ for (let [x = 'a' in {}] = []; !x; x = !x) console.log(x) - 4 │ for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x) - · ─┬ - · ╰── `,` expected - ╰──── - Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Identifier `orbitol` has already been declared ╭─[conformance/salsa/plainJSRedeclare3.ts:4:1] @@ -9782,6 +9780,22 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 3 │ } ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath.ts:12:1] + 12 │ + 13 │ declare module debugger {} // still an error + · ─ + ╰──── + help: Try insert a semicolon here + + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[conformance/ambient/ambientModuleDeclarationWithReservedIdentifierInDottedPath2.ts:10:1] + 10 │ + 11 │ declare namespace debugger {} // still an error + · ─ + ╰──── + help: Try insert a semicolon here + × Cannot use `await` as an identifier in an async context ╭─[conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts:3:1] 3 │ @@ -17574,14 +17588,6 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 2 │ } ╰──── - × Expected `,` but found `in` - ╭─[conformance/parser/ecmascript5/Statements/parserForInStatement8.ts:3:1] - 3 │ for (let [x = 'a' in {}] in { '': 0 }) console.log(x) - 4 │ for (let {x = 'a' in {}} in { '': 0 }) console.log(x) - · ─┬ - · ╰── `,` expected - ╰──── - × Unexpected token ╭─[conformance/parser/ecmascript5/Statements/parserForStatement4.ts:1:1] 1 │ for (a = 1 in b) { @@ -18000,14 +18006,6 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" · ───── ╰──── - × Expected `,` but found `in` - ╭─[conformance/parser/ecmascript6/Iterators/parserForOfStatement25.ts:5:1] - 5 │ for (let [x = 'a' in {}] of [[]]) console.log(x) - 6 │ for (let {x = 'a' in {}} of [{}]) console.log(x) - · ─┬ - · ╰── `,` expected - ╰──── - × Only a single declaration is allowed in a `for...of` statement ╭─[conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts:1:1] 1 │ //@target: ES6 diff --git a/tasks/coverage/test262 b/tasks/coverage/test262 index eb613f68914c..59bad8989833 160000 --- a/tasks/coverage/test262 +++ b/tasks/coverage/test262 @@ -1 +1 @@ -Subproject commit eb613f68914c978e6d6369e5f2415fa8f5fabbfd +Subproject commit 59bad89898333fdadf4af25519e7bdb43ec295ac diff --git a/tasks/coverage/typescript b/tasks/coverage/typescript index 4b15830a1fb2..9cbcf010ce07 160000 --- a/tasks/coverage/typescript +++ b/tasks/coverage/typescript @@ -1 +1 @@ -Subproject commit 4b15830a1fb20a89e9c22847e05c3f88a0a31531 +Subproject commit 9cbcf010ce0701a25f01a2a074000db34f80cc17 From 3b8639842f139181b5d714490df2d8c7b2e5d322 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Sat, 16 Sep 2023 11:58:20 +0100 Subject: [PATCH 10/23] add check, update snap --- crates/oxc_parser/src/diagnostics.rs | 5 +++ crates/oxc_parser/src/js/declaration.rs | 12 +++++-- tasks/coverage/parser_typescript.snap | 46 ++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index fe660d83c999..99613b69f1ea 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -291,3 +291,8 @@ pub struct LineTerminatorBeforeUsingDeclaration(#[label] pub Span); #[error("Await is not allowed in using declarations")] #[diagnostic()] pub struct AwaitInUsingDeclaration(#[label] pub Span); + +#[derive(Debug, Error, Diagnostic)] +#[error("Using declarations may not have binding patterns")] +#[diagnostic()] +pub struct InvalidIdentifierInUsingDeclaration(#[label] pub Span); diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index 6c57c8405b25..999d41d5cc2c 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -132,14 +132,22 @@ impl<'a> Parser<'a> { } // BindingList[?In, ?Yield, ?Await, ~Pattern] - // TODO: work out how to exclude pattern - // TODO: add to context? let mut declarations: oxc_allocator::Vec<'_, VariableDeclarator<'_>> = self.ast.new_vec(); loop { let declaration = self.parse_variable_declarator( VariableDeclarationContext::new(VariableDeclarationParent::Statement), VariableDeclarationKind::Var, )?; + + match declaration.id.kind { + BindingPatternKind::BindingIdentifier(_) => {} + _ => { + self.error(diagnostics::InvalidIdentifierInUsingDeclaration( + declaration.id.span(), + )); + } + } + declarations.push(declaration); if !self.eat(Kind::Comma) { break; diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 47e755a408fb..6c3772e45931 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,7 +1,7 @@ parser_typescript Summary: AST Parsed : 5158/5162 (99.92%) Positive Passed: 5150/5162 (99.77%) -Negative Passed: 1014/4831 (20.99%) +Negative Passed: 1018/4831 (21.07%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -3382,8 +3382,6 @@ Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclaration Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts" @@ -3392,8 +3390,6 @@ Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclaration Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts" @@ -18390,6 +18386,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 8 │ } ╰──── + × Using declarations may not have binding patterns + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts:7:1] + 7 │ await using a = null, + 8 │ [b] = null, + · ─── + 9 │ c = null; + ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts:6:1] 6 │ { @@ -18399,9 +18403,25 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── help: Try insert a semicolon here + × Using declarations may not have binding patterns + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts:7:1] + 7 │ await using a = null, + 8 │ {b} = null, + · ─── + 9 │ c = null; + ╰──── + × Missing initializer in destructuring declaration ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts:6:1] 6 │ async function main() { + 7 │ for (await using {} of []) { + · ── + 8 │ } + ╰──── + + × Using declarations may not have binding patterns + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts:6:1] + 6 │ async function main() { 7 │ for (await using {} of []) { · ── 8 │ } @@ -18415,6 +18435,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 7 │ declare using y: null; ╰──── + × Using declarations may not have binding patterns + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts:7:1] + 7 │ using a = null, + 8 │ [b] = null, + · ─── + 9 │ c = null; + ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.6.ts:6:1] 6 │ { @@ -18424,6 +18452,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── help: Try insert a semicolon here + × Using declarations may not have binding patterns + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts:7:1] + 7 │ using a = null, + 8 │ {b} = null, + · ─── + 9 │ c = null; + ╰──── + × Unexpected token ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts:5:1] 5 │ From 760767f2408fade54178c3f53705e58145de0104 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Sat, 16 Sep 2023 16:04:21 +0100 Subject: [PATCH 11/23] rename var --- crates/oxc_parser/src/js/statement.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index e1b3441985f0..f2f245bd21c6 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -278,15 +278,14 @@ impl<'a> Parser<'a> { if (self.cur_kind() == Kind::Await && self.peek_kind() == Kind::Using) || (self.cur_kind() == Kind::Using && self.peek_kind() == Kind::Ident) { - // TODO: rename variables - let x = self.parse_using_declaration()?; + let using_decl = self.parse_using_declaration()?; if matches!(self.cur_kind(), Kind::In | Kind::Of) { - let init = ForStatementLeft::UsingDeclaration(self.ast.alloc(x)); + let init = ForStatementLeft::UsingDeclaration(self.ast.alloc(using_decl)); return self.parse_for_in_or_of_loop(span, r#await, init); } - let init = Some(ForStatementInit::UsingDeclaration(self.ast.alloc(x))); + let init = Some(ForStatementInit::UsingDeclaration(self.ast.alloc(using_decl))); return self.parse_for_loop(span, init, r#await); } From fb520301d3f3c4d19b842ac6ff789ef0ccb896cb Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Sat, 16 Sep 2023 21:40:57 +0100 Subject: [PATCH 12/23] tag for-of-using decl correctly --- crates/oxc_ast/src/ast/js.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index babecb2837a1..b27232608bf8 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1957,7 +1957,7 @@ impl ModuleExportName { } #[derive(Debug, Hash)] -#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))] pub struct UsingDeclaration<'a> { #[cfg_attr(feature = "serde", serde(flatten))] pub span: Span, From 5b1ff5d6b94a39e109e90905eb10e06755261c8c Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 19 Sep 2023 20:58:20 +0100 Subject: [PATCH 13/23] just sync --- tasks/coverage/babel | 2 +- tasks/coverage/parser_typescript.snap | 4 ++-- tasks/coverage/test262 | 2 +- tasks/coverage/typescript | 2 +- tasks/transform_conformance/babel.snap.md | 23 ++++++++++++++++++++++- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tasks/coverage/babel b/tasks/coverage/babel index feef4b1c2f46..0d8b6df9ff8c 160000 --- a/tasks/coverage/babel +++ b/tasks/coverage/babel @@ -1 +1 @@ -Subproject commit feef4b1c2f4666e91d612273cd7bfdc2ca3df5b6 +Subproject commit 0d8b6df9ff8cdff35ea781a688946a0bdabee33c diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 6c3772e45931..5ed88aa34114 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,6 +1,6 @@ parser_typescript Summary: -AST Parsed : 5158/5162 (99.92%) -Positive Passed: 5150/5162 (99.77%) +AST Parsed : 5159/5163 (99.92%) +Positive Passed: 5151/5163 (99.77%) Negative Passed: 1018/4831 (21.07%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" diff --git a/tasks/coverage/test262 b/tasks/coverage/test262 index 59bad8989833..79f087814fb2 160000 --- a/tasks/coverage/test262 +++ b/tasks/coverage/test262 @@ -1 +1 @@ -Subproject commit 59bad89898333fdadf4af25519e7bdb43ec295ac +Subproject commit 79f087814fb2e821619e0a27fc7272f8f2bef317 diff --git a/tasks/coverage/typescript b/tasks/coverage/typescript index 9cbcf010ce07..7d9399e353c1 160000 --- a/tasks/coverage/typescript +++ b/tasks/coverage/typescript @@ -1 +1 @@ -Subproject commit 9cbcf010ce0701a25f01a2a074000db34f80cc17 +Subproject commit 7d9399e353c1b770ab1b5c859c98e014cd3fda03 diff --git a/tasks/transform_conformance/babel.snap.md b/tasks/transform_conformance/babel.snap.md index 7a1c45439971..f3f28b44091f 100644 --- a/tasks/transform_conformance/babel.snap.md +++ b/tasks/transform_conformance/babel.snap.md @@ -1,4 +1,4 @@ -Passed: 86/1071 +Passed: 86/1092 # babel-plugin-transform-class-properties * Failed: assumption-constantSuper/complex-super-class/input.js @@ -19,6 +19,7 @@ Passed: 86/1071 * Failed: assumption-setPublicClassFields/regression-T6719/input.js * Failed: assumption-setPublicClassFields/regression-T7364/input.mjs * Failed: assumption-setPublicClassFields/static/input.js +* Failed: assumption-setPublicClassFields/static-class-binding/input.js * Failed: assumption-setPublicClassFields/static-export/input.mjs * Failed: assumption-setPublicClassFields/static-infer-name/input.js * Failed: assumption-setPublicClassFields/static-super/input.js @@ -108,6 +109,7 @@ Passed: 86/1071 * Failed: private/regression-T7364/input.mjs * Failed: private/static/input.js * Failed: private/static-call/input.js +* Failed: private/static-class-binding/input.js * Failed: private/static-export/input.mjs * Failed: private/static-infer-name/input.js * Failed: private/static-inherited/input.js @@ -179,6 +181,7 @@ Passed: 86/1071 * Failed: private-loose/reference-in-other-property/input.js * Failed: private-loose/static/input.js * Failed: private-loose/static-call/input.js +* Failed: private-loose/static-class-binding/input.js * Failed: private-loose/static-export/input.mjs * Failed: private-loose/static-infer-name/input.js * Failed: private-loose/static-inherited/input.js @@ -216,6 +219,7 @@ Passed: 86/1071 * Failed: public/regression-T6719/input.js * Failed: public/regression-T7364/input.mjs * Failed: public/static/input.js +* Failed: public/static-class-binding/input.js * Failed: public/static-export/input.mjs * Failed: public/static-infer-name/input.js * Failed: public/static-super/input.js @@ -241,6 +245,7 @@ Passed: 86/1071 * Failed: public-loose/regression-T6719/input.js * Failed: public-loose/regression-T7364/input.mjs * Failed: public-loose/static/input.js +* Failed: public-loose/static-class-binding/input.js * Failed: public-loose/static-export/input.mjs * Failed: public-loose/static-infer-name/input.js * Failed: public-loose/static-super/input.js @@ -294,6 +299,7 @@ Passed: 86/1071 # babel-plugin-transform-private-methods * Failed: accessors/basic/input.js +* Failed: accessors/class-binding/input.js * Failed: accessors/get-only-setter/input.js * Failed: accessors/preserve-comments/input.js * Failed: accessors/reassignment/input.js @@ -302,17 +308,20 @@ Passed: 86/1071 * Failed: accessors/updates/input.js * Failed: accessors/updates-bigint/input.js * Failed: accessors-loose/basic/input.js +* Failed: accessors-loose/class-binding/input.js * Failed: accessors-loose/get-only-setter/input.js * Failed: accessors-loose/preserve-comments/input.js * Failed: accessors-loose/reassignment/input.js * Failed: accessors-loose/set-only-getter/input.js * Failed: accessors-loose/updates/input.js * Failed: accessors-privateFieldsAsProperties/basic/input.js +* Failed: accessors-privateFieldsAsProperties/class-binding/input.js * Failed: accessors-privateFieldsAsProperties/get-only-setter/input.js * Failed: accessors-privateFieldsAsProperties/preserve-comments/input.js * Failed: accessors-privateFieldsAsProperties/set-only-getter/input.js * Failed: accessors-privateFieldsAsProperties/updates/input.js * Failed: accessors-privateFieldsAsSymbols/basic/input.js +* Failed: accessors-privateFieldsAsSymbols/class-binding/input.js * Failed: accessors-privateFieldsAsSymbols/get-only-setter/input.js * Failed: accessors-privateFieldsAsSymbols/preserve-comments/input.js * Failed: accessors-privateFieldsAsSymbols/set-only-getter/input.js @@ -330,6 +339,7 @@ Passed: 86/1071 * Failed: private-method/assignment/input.js * Failed: private-method/async/input.js * Failed: private-method/before-fields/input.js +* Failed: private-method/class-binding/input.js * Failed: private-method/class-expression/input.js * Failed: private-method/context/input.js * Failed: private-method/exfiltrated/input.js @@ -342,6 +352,7 @@ Passed: 86/1071 * Failed: private-method-loose/assignment/input.js * Failed: private-method-loose/async/input.js * Failed: private-method-loose/before-fields/input.js +* Failed: private-method-loose/class-binding/input.js * Failed: private-method-loose/class-expression/input.js * Failed: private-method-loose/context/input.js * Failed: private-method-loose/exfiltrated/input.js @@ -352,6 +363,7 @@ Passed: 86/1071 * Failed: private-method-privateFieldsAsProperties/assignment/input.js * Failed: private-method-privateFieldsAsProperties/async/input.js * Failed: private-method-privateFieldsAsProperties/before-fields/input.js +* Failed: private-method-privateFieldsAsProperties/class-binding/input.js * Failed: private-method-privateFieldsAsProperties/class-expression/input.js * Failed: private-method-privateFieldsAsProperties/context/input.js * Failed: private-method-privateFieldsAsProperties/exfiltrated/input.js @@ -360,6 +372,7 @@ Passed: 86/1071 * Failed: private-method-privateFieldsAsSymbols/assignment/input.js * Failed: private-method-privateFieldsAsSymbols/async/input.js * Failed: private-method-privateFieldsAsSymbols/before-fields/input.js +* Failed: private-method-privateFieldsAsSymbols/class-binding/input.js * Failed: private-method-privateFieldsAsSymbols/class-expression/input.js * Failed: private-method-privateFieldsAsSymbols/context/input.js * Failed: private-method-privateFieldsAsSymbols/exfiltrated/input.js @@ -565,6 +578,7 @@ Passed: 86/1071 * Failed: general/cast-to-boolean/input.js * Failed: general/containers/input.js * Failed: general/delete/input.js +* Failed: general/delete-in-function-params/input.js * Failed: general/function-call/input.js * Failed: general/function-call-loose/input.js * Failed: general/function-call-spread/input.js @@ -590,6 +604,7 @@ Passed: 86/1071 * Failed: loose/cast-to-boolean/input.js * Failed: regression/10959-transform-optional-chaining/input.ts * Failed: regression/10959-transform-ts-and-optional-chaining/input.ts +* Failed: regression/15887/input.js * Failed: regression/7642/input.js * Failed: transparent-expr-wrappers/ts-as-call-context/input.ts * Failed: transparent-expr-wrappers/ts-as-call-context-in-if/input.ts @@ -734,6 +749,7 @@ Passed: 86/1071 * Failed: export-async/default-export/input.mjs * Failed: export-async/import-and-export/input.mjs * Failed: export-async/lone-export/input.mjs +* Failed: regression/15978/input.js * Failed: regression/4599/input.js * Failed: regression/4943/input.js * Failed: regression/7178/input.js @@ -742,6 +758,7 @@ Passed: 86/1071 * Failed: regression/T7194/input.js * Failed: regression/gh-6923/input.js * Failed: regression/in-uncompiled-class-fields/input.js +* Failed: regression/regression-2765/input.js * Passed: assumption-noNewArrows-false/bluebird/input.js # babel-plugin-transform-exponentiation-operator @@ -870,6 +887,7 @@ Passed: 86/1071 * Failed: namespace/contentious-names/input.ts * Failed: namespace/declare/input.ts * Failed: namespace/declare-global-nested-namespace/input.ts +* Failed: namespace/empty-removed/input.ts * Failed: namespace/export/input.ts * Failed: namespace/module-nested/input.ts * Failed: namespace/module-nested-export/input.ts @@ -877,7 +895,9 @@ Passed: 86/1071 * Failed: namespace/namespace-nested-module/input.ts * Failed: namespace/nested/input.ts * Failed: namespace/nested-destructuring/input.ts +* Failed: namespace/nested-namespace/input.ts * Failed: namespace/nested-shorthand/input.ts +* Failed: namespace/nested-shorthand-export/input.ts * Failed: namespace/same-name/input.ts * Failed: namespace/undeclared/input.ts * Failed: optimize-const-enums/custom-values/input.ts @@ -894,6 +914,7 @@ Passed: 86/1071 * Failed: regression/10162/input.ts * Failed: regression/10338/input.ts * Failed: regression/11061/input.mjs +* Failed: regression/15768/input.ts * Failed: type-arguments/tsx/input.ts * Failed: type-arguments/tsx-babel-7/input.ts * Failed: variable-declaration/non-null-in-optional-chain/input.ts From f57d61c517549d54770ac52674f2bdbceb8a0311 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 19 Sep 2023 21:01:52 +0100 Subject: [PATCH 14/23] move block --- crates/oxc_ast/src/ast/js.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index b27232608bf8..bd68568be59c 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1070,6 +1070,16 @@ pub struct VariableDeclarator<'a> { pub definite: bool, } +#[derive(Debug, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))] +pub struct UsingDeclaration<'a> { + #[cfg_attr(feature = "serde", serde(flatten))] + pub span: Span, + pub is_await: bool, + #[cfg_attr(feature = "serde-impl", serde(default))] + pub declarations: Vec<'a, VariableDeclarator<'a>>, +} + /// Empty Statement #[derive(Debug, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))] @@ -1955,13 +1965,3 @@ impl ModuleExportName { } } } - -#[derive(Debug, Hash)] -#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))] -pub struct UsingDeclaration<'a> { - #[cfg_attr(feature = "serde", serde(flatten))] - pub span: Span, - pub is_await: bool, - #[cfg_attr(feature = "serde-impl", serde(default))] - pub declarations: Vec<'a, VariableDeclarator<'a>>, -} From c474d4712ad4cd3fbd3867a0c16d4d41774968b0 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 19 Sep 2023 21:28:08 +0100 Subject: [PATCH 15/23] minor fixes --- crates/oxc_parser/src/diagnostics.rs | 10 ++++++++++ crates/oxc_parser/src/js/declaration.rs | 2 +- crates/oxc_parser/src/js/statement.rs | 12 ++++++++++++ tasks/coverage/parser_typescript.snap | 20 +++++++++++++++++--- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index 99613b69f1ea..a26823011321 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -296,3 +296,13 @@ pub struct AwaitInUsingDeclaration(#[label] pub Span); #[error("Using declarations may not have binding patterns")] #[diagnostic()] pub struct InvalidIdentifierInUsingDeclaration(#[label] pub Span); + +#[derive(Debug, Error, Diagnostic)] +#[error("The left-hand side of a for...in statement cannot be an await using declaration")] +#[diagnostic()] +pub struct AwaitUsingDeclarationNotAllowedInForInStatement(#[label] pub Span); + +#[derive(Debug, Error, Diagnostic)] +#[error("The left-hand side of a for...in statement cannot be an using declaration")] +#[diagnostic()] +pub struct UsingDeclarationNotAllowedInForInStatement(#[label] pub Span); diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index 999d41d5cc2c..e5f2cb0dfb91 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -154,6 +154,6 @@ impl<'a> Parser<'a> { } } - Ok(self.ast.using_declaration(span, declarations, is_await)) + Ok(self.ast.using_declaration(self.end_span(span), declarations, is_await)) } } diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index f2f245bd21c6..3105cfc69695 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -280,6 +280,18 @@ impl<'a> Parser<'a> { { let using_decl = self.parse_using_declaration()?; + if matches!(self.cur_kind(), Kind::In) { + if using_decl.is_await { + self.error(diagnostics::AwaitUsingDeclarationNotAllowedInForInStatement( + using_decl.span, + )); + } else { + self.error(diagnostics::UsingDeclarationNotAllowedInForInStatement( + using_decl.span, + )); + } + } + if matches!(self.cur_kind(), Kind::In | Kind::Of) { let init = ForStatementLeft::UsingDeclaration(self.ast.alloc(using_decl)); return self.parse_for_in_or_of_loop(span, r#await, init); diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 5ed88aa34114..336e9f138b5b 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,7 +1,7 @@ parser_typescript Summary: AST Parsed : 5159/5163 (99.92%) Positive Passed: 5151/5163 (99.77%) -Negative Passed: 1018/4831 (21.07%) +Negative Passed: 1020/4831 (21.11%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -3384,7 +3384,6 @@ Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclaration Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts" @@ -3392,7 +3391,6 @@ Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclaration Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts" Expect Syntax Error: "conformance/statements/breakStatements/invalidSwitchBreakStatement.ts" Expect Syntax Error: "conformance/statements/breakStatements/switchBreakStatements.ts" @@ -18411,6 +18409,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 9 │ c = null; ╰──── + × The left-hand side of a for...in statement cannot be an await using declaration + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts:6:1] + 6 │ async function main() { + 7 │ for (await using x in {}) { + · ───────────── + 8 │ } + ╰──── + × Missing initializer in destructuring declaration ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts:6:1] 6 │ async function main() { @@ -18460,6 +18466,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 9 │ c = null; ╰──── + × The left-hand side of a for...in statement cannot be an using declaration + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts:5:1] + 5 │ + 6 │ for (using x in {}) { + · ─────── + 7 │ } + ╰──── + × Unexpected token ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts:5:1] 5 │ From 0ba0236bc8a57f7beeb51dee48b7127804b1ade2 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 19 Sep 2023 21:48:00 +0100 Subject: [PATCH 16/23] more errors --- crates/oxc_parser/src/diagnostics.rs | 15 +++++++---- crates/oxc_parser/src/js/declaration.rs | 12 +++++++-- crates/oxc_parser/src/js/statement.rs | 4 ++- tasks/coverage/parser_typescript.snap | 34 +++++++++++++++++-------- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index a26823011321..ee0d4ed6dbd8 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -283,26 +283,31 @@ pub struct ReturnStatementOnlyInFunctionBody(#[label] pub Span); pub struct JSXExpressionsMayNotUseTheCommaOperator(#[label] pub Span); #[derive(Debug, Error, Diagnostic)] -#[error("Line terminator not permitted before using declaration")] +#[error("Line terminator not permitted before using declaration.")] #[diagnostic()] pub struct LineTerminatorBeforeUsingDeclaration(#[label] pub Span); #[derive(Debug, Error, Diagnostic)] -#[error("Await is not allowed in using declarations")] +#[error("Await is not allowed in using declarations.")] #[diagnostic()] pub struct AwaitInUsingDeclaration(#[label] pub Span); #[derive(Debug, Error, Diagnostic)] -#[error("Using declarations may not have binding patterns")] +#[error("Using declarations may not have binding patterns.")] #[diagnostic()] pub struct InvalidIdentifierInUsingDeclaration(#[label] pub Span); #[derive(Debug, Error, Diagnostic)] -#[error("The left-hand side of a for...in statement cannot be an await using declaration")] +#[error("The left-hand side of a for...in statement cannot be an await using declaration.")] #[diagnostic()] pub struct AwaitUsingDeclarationNotAllowedInForInStatement(#[label] pub Span); #[derive(Debug, Error, Diagnostic)] -#[error("The left-hand side of a for...in statement cannot be an using declaration")] +#[error("The left-hand side of a for...in statement cannot be an using declaration.")] #[diagnostic()] pub struct UsingDeclarationNotAllowedInForInStatement(#[label] pub Span); + +#[derive(Debug, Error, Diagnostic)] +#[error("Using declarations must have an initializer.")] +#[diagnostic()] +pub struct UsingDeclarationsMustBeInitialized(#[label] pub Span); diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index e5f2cb0dfb91..b91ae683d950 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -43,7 +43,7 @@ impl<'a> Parser<'a> { } pub(crate) fn parse_using(&mut self) -> Result> { - let using_decl = self.parse_using_declaration()?; + let using_decl = self.parse_using_declaration(StatementContext::StatementList)?; self.expect(Kind::Semicolon)?; @@ -113,7 +113,10 @@ impl<'a> Parser<'a> { /// UsingDeclaration[In, Yield, Await] : /// using [no LineTerminator here] [lookahead ≠ await] BindingList[?In, ?Yield, ?Await, ~Pattern] ; - pub(crate) fn parse_using_declaration(&mut self) -> Result> { + pub(crate) fn parse_using_declaration( + &mut self, + statement_ctx: StatementContext, + ) -> Result> { let span = self.start_span(); let is_await = self.eat(Kind::Await); @@ -148,6 +151,11 @@ impl<'a> Parser<'a> { } } + // Excluding `for` loops, an initializer is required in a UsingDeclaration. + if declaration.init.is_none() && !matches!(statement_ctx, StatementContext::For) { + self.error(diagnostics::UsingDeclarationsMustBeInitialized(declaration.id.span())); + } + declarations.push(declaration); if !self.eat(Kind::Comma) { break; diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index 3105cfc69695..5d4ba9a82a0c 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -122,6 +122,8 @@ impl<'a> Parser<'a> { self.parse_variable_statement(stmt_ctx) } Kind::Let if !self.cur_token().escaped => self.parse_let(stmt_ctx), + // TODO: investigate whether we can get better error messages by not checking `self.nth_kind(2).is_binding_identifier()` + // and instead attempting to parse the using declaration and then checking if it is valid. Kind::Await if self.peek_kind() == Kind::Using && self.nth_kind(2).is_binding_identifier() => { @@ -278,7 +280,7 @@ impl<'a> Parser<'a> { if (self.cur_kind() == Kind::Await && self.peek_kind() == Kind::Using) || (self.cur_kind() == Kind::Using && self.peek_kind() == Kind::Ident) { - let using_decl = self.parse_using_declaration()?; + let using_decl = self.parse_using_declaration(StatementContext::For)?; if matches!(self.cur_kind(), Kind::In) { if using_decl.is_await { diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 336e9f138b5b..44b78cdcabee 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,7 +1,7 @@ parser_typescript Summary: AST Parsed : 5159/5163 (99.92%) Positive Passed: 5151/5163 (99.77%) -Negative Passed: 1020/4831 (21.11%) +Negative Passed: 1022/4831 (21.16%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -3382,14 +3382,12 @@ Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclaration Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts" -Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts" Expect Syntax Error: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts" Expect Syntax Error: "conformance/statements/breakStatements/invalidSwitchBreakStatement.ts" @@ -18384,7 +18382,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 8 │ } ╰──── - × Using declarations may not have binding patterns + × Using declarations may not have binding patterns. ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts:7:1] 7 │ await using a = null, 8 │ [b] = null, @@ -18401,7 +18399,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── help: Try insert a semicolon here - × Using declarations may not have binding patterns + × Using declarations may not have binding patterns. ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts:7:1] 7 │ await using a = null, 8 │ {b} = null, @@ -18409,7 +18407,15 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 9 │ c = null; ╰──── - × The left-hand side of a for...in statement cannot be an await using declaration + × Using declarations must have an initializer. + ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts:6:1] + 6 │ { + 7 │ await using a; + · ─ + 8 │ } + ╰──── + + × The left-hand side of a for...in statement cannot be an await using declaration. ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts:6:1] 6 │ async function main() { 7 │ for (await using x in {}) { @@ -18425,7 +18431,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 8 │ } ╰──── - × Using declarations may not have binding patterns + × Using declarations may not have binding patterns. ╭─[conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts:6:1] 6 │ async function main() { 7 │ for (await using {} of []) { @@ -18441,7 +18447,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 7 │ declare using y: null; ╰──── - × Using declarations may not have binding patterns + × Using declarations may not have binding patterns. ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts:7:1] 7 │ using a = null, 8 │ [b] = null, @@ -18458,7 +18464,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── help: Try insert a semicolon here - × Using declarations may not have binding patterns + × Using declarations may not have binding patterns. ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts:7:1] 7 │ using a = null, 8 │ {b} = null, @@ -18466,7 +18472,15 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 9 │ c = null; ╰──── - × The left-hand side of a for...in statement cannot be an using declaration + × Using declarations must have an initializer. + ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts:6:1] + 6 │ { + 7 │ using a; + · ─ + 8 │ } + ╰──── + + × The left-hand side of a for...in statement cannot be an using declaration. ╭─[conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts:5:1] 5 │ 6 │ for (using x in {}) { From 20f57b189f0fd97812e19fd8b0f95af6dc5540ac Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Fri, 29 Sep 2023 22:30:55 +0100 Subject: [PATCH 17/23] just coverage --- tasks/coverage/babel | 2 +- tasks/coverage/formatter_babel.snap | 4 +- tasks/coverage/formatter_test262.snap | 4 +- tasks/coverage/parser_babel.snap | 56 ++++++++++++++++++++--- tasks/coverage/parser_test262.snap | 4 +- tasks/coverage/parser_typescript.snap | 39 ++++++++++++++-- tasks/coverage/test262 | 2 +- tasks/coverage/typescript | 2 +- tasks/transform_conformance/babel.snap.md | 24 ++++++++-- 9 files changed, 111 insertions(+), 26 deletions(-) diff --git a/tasks/coverage/babel b/tasks/coverage/babel index 0d8b6df9ff8c..b5d6c3c820af 160000 --- a/tasks/coverage/babel +++ b/tasks/coverage/babel @@ -1 +1 @@ -Subproject commit 0d8b6df9ff8cdff35ea781a688946a0bdabee33c +Subproject commit b5d6c3c820af3c049b476df6e885fef33fa953f1 diff --git a/tasks/coverage/formatter_babel.snap b/tasks/coverage/formatter_babel.snap index 1ca9e03396f2..517c0e933b02 100644 --- a/tasks/coverage/formatter_babel.snap +++ b/tasks/coverage/formatter_babel.snap @@ -1,6 +1,6 @@ formatter_babel Summary: -AST Parsed : 2083/2083 (100.00%) -Positive Passed: 2060/2083 (98.90%) +AST Parsed : 2096/2096 (100.00%) +Positive Passed: 2073/2096 (98.90%) Expect to Parse: "typescript/cast/nested-parenthesized-assert-and-assign/input.ts" Expect to Parse: "typescript/class/abstract/input.ts" Expect to Parse: "typescript/class/declare/input.ts" diff --git a/tasks/coverage/formatter_test262.snap b/tasks/coverage/formatter_test262.snap index 2412ef4542a7..f185ed00ea45 100644 --- a/tasks/coverage/formatter_test262.snap +++ b/tasks/coverage/formatter_test262.snap @@ -1,3 +1,3 @@ formatter_test262 Summary: -AST Parsed : 45471/45471 (100.00%) -Positive Passed: 45471/45471 (100.00%) +AST Parsed : 45485/45485 (100.00%) +Positive Passed: 45485/45485 (100.00%) diff --git a/tasks/coverage/parser_babel.snap b/tasks/coverage/parser_babel.snap index 7b0b364ec148..a84e44f82ed2 100644 --- a/tasks/coverage/parser_babel.snap +++ b/tasks/coverage/parser_babel.snap @@ -1,7 +1,7 @@ parser_babel Summary: -AST Parsed : 2077/2083 (99.71%) -Positive Passed: 2074/2083 (99.57%) -Negative Passed: 1342/1495 (89.77%) +AST Parsed : 2090/2096 (99.71%) +Positive Passed: 2087/2096 (99.57%) +Negative Passed: 1349/1499 (89.99%) Expect Syntax Error: "annex-b/disabled/1.1-html-comments-close/input.js" Expect Syntax Error: "annex-b/disabled/3.1-sloppy-labeled-functions/input.js" Expect Syntax Error: "annex-b/disabled/3.1-sloppy-labeled-functions-if-body/input.js" @@ -33,6 +33,7 @@ Expect Syntax Error: "es2018/object-rest-spread/comma-after-spread-nested/input. Expect Syntax Error: "es2018/object-rest-spread/no-pattern-in-rest/input.js" Expect Syntax Error: "es2018/object-rest-spread/no-pattern-in-rest-with-ts/input.js" Expect Syntax Error: "es2020/dynamic-import/invalid-trailing-comma/input.js" +Expect Syntax Error: "es2020/dynamic-import-createImportExpression-false/invalid-trailing-comma/input.js" Expect Syntax Error: "esprima/es2015-arrow-function/invalid-param-strict-mode/input.js" Expect Syntax Error: "esprima/es2015-generator/generator-parameter-binding-property-reserved/input.js" Expect Syntax Error: "esprima/invalid-syntax/migrated_0101/input.js" @@ -149,12 +150,8 @@ Expect Syntax Error: "typescript/types/read-only-1/input.ts" Expect Syntax Error: "typescript/types/read-only-2/input.ts" Expect Syntax Error: "typescript/types/read-only-3/input.ts" Expect Syntax Error: "typescript/types/read-only-4/input.ts" -Expect Syntax Error: "typescript/types/tuple-labeled-after-unlabeled/input.ts" -Expect Syntax Error: "typescript/types/tuple-labeled-before-unlabeled/input.ts" Expect Syntax Error: "typescript/types/tuple-optional-invalid/input.ts" Expect Syntax Error: "typescript/types/tuple-required-after-labeled-optional/input.ts" -Expect Syntax Error: "typescript/types/tuple-unlabeled-spread-after-labeled/input.ts" -Expect Syntax Error: "typescript/types/tuple-unlabeled-spread-before-labeled/input.ts" Expect to Parse: "core/opts/allowNewTargetOutsideFunction-true/input.js" × Unexpected new.target expression ╭─[core/opts/allowNewTargetOutsideFunction-true/input.js:1:1] @@ -5310,6 +5307,12 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─── ╰──── + × Unexpected token + ╭─[es2020/dynamic-import/invalid-lone-import/input.js:1:1] + 1 │ (import) + · ─ + ╰──── + × Cannot use new with dynamic import ╭─[es2020/dynamic-import/invalid-new/input.js:1:1] 1 │ new import("foo"); @@ -5329,6 +5332,45 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts" · ─ ╰──── + × The only valid meta property for import is import.meta + ╭─[es2020/dynamic-import-createImportExpression-false/direct-calls-only/input.js:1:1] + 1 │ function failsParse() { + 2 │ return import.then(); + · ─────────── + 3 │ } + ╰──── + + × Unexpected token + ╭─[es2020/dynamic-import-createImportExpression-false/invalid-arguments-spread/input.js:1:1] + 1 │ import(...[1]) + · ─── + ╰──── + + × Unexpected token + ╭─[es2020/dynamic-import-createImportExpression-false/invalid-lone-import/input.js:1:1] + 1 │ (import) + · ─ + ╰──── + + × Cannot use new with dynamic import + ╭─[es2020/dynamic-import-createImportExpression-false/invalid-new/input.js:1:1] + 1 │ new import("foo"); + · ───────────── + ╰──── + + × Expected `)` but found `string` + ╭─[es2020/dynamic-import-createImportExpression-false/multiple-args/input.js:1:1] + 1 │ import('hello', 'world', '!'); + · ─┬─ + · ╰── `)` expected + ╰──── + + × Unexpected token + ╭─[es2020/dynamic-import-createImportExpression-false/no-args/input.js:1:1] + 1 │ import(); + · ─ + ╰──── + × Unexpected import.meta expression ╭─[es2020/import-meta/error-in-script/input.js:1:1] 1 │ const x = import.meta; diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index f6a3f13cd5e8..fe681ff97894 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -1,6 +1,6 @@ parser_test262 Summary: -AST Parsed : 44947/44947 (100.00%) -Positive Passed: 44947/44947 (100.00%) +AST Parsed : 44961/44961 (100.00%) +Positive Passed: 44961/44961 (100.00%) Negative Passed: 3919/3947 (99.29%) Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-01.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-02.js" diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 1d65c08dca44..c7bde3642c1e 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,7 +1,7 @@ parser_typescript Summary: -AST Parsed : 5159/5163 (99.92%) -Positive Passed: 5151/5163 (99.77%) -Negative Passed: 1022/4831 (21.16%) +AST Parsed : 5166/5170 (99.92%) +Positive Passed: 5158/5170 (99.77%) +Negative Passed: 1023/4841 (21.13%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -278,6 +278,9 @@ Expect Syntax Error: "compiler/classExtendsMultipleBaseClasses.ts" Expect Syntax Error: "compiler/classExtendsNull.ts" Expect Syntax Error: "compiler/classExtendsNull2.ts" Expect Syntax Error: "compiler/classExtendsNull3.ts" +Expect Syntax Error: "compiler/classFieldSuperAccessibleJs1.ts" +Expect Syntax Error: "compiler/classFieldSuperNotAccessible.ts" +Expect Syntax Error: "compiler/classFieldSuperNotAccessibleJs.ts" Expect Syntax Error: "compiler/classImplementsClass2.ts" Expect Syntax Error: "compiler/classImplementsClass4.ts" Expect Syntax Error: "compiler/classImplementsClass5.ts" @@ -1488,6 +1491,7 @@ Expect Syntax Error: "compiler/recursiveTypeParameterConstraintReferenceLacksTyp Expect Syntax Error: "compiler/recursiveTypeRelations.ts" Expect Syntax Error: "compiler/recursivelyExpandingUnionNoStackoverflow.ts" Expect Syntax Error: "compiler/redefineArray.ts" +Expect Syntax Error: "compiler/relationComplexityError.ts" Expect Syntax Error: "compiler/relationalOperatorComparable.ts" Expect Syntax Error: "compiler/renamingDestructuredPropertyInFunctionType.ts" Expect Syntax Error: "compiler/renamingDestructuredPropertyInFunctionType3.ts" @@ -2215,6 +2219,7 @@ Expect Syntax Error: "conformance/dynamicImport/importCallExpressionSpecifierNot Expect Syntax Error: "conformance/enums/enumConstantMemberWithString.ts" Expect Syntax Error: "conformance/enums/enumConstantMemberWithTemplateLiterals.ts" Expect Syntax Error: "conformance/enums/enumConstantMembers.ts" +Expect Syntax Error: "conformance/enums/enumErrorOnConstantBindingWithInitializer.ts" Expect Syntax Error: "conformance/enums/enumMergingErrors.ts" Expect Syntax Error: "conformance/enums/enumShadowedInfinityNaN.ts" Expect Syntax Error: "conformance/es2017/useObjectValuesAndEntries2.ts" @@ -2614,6 +2619,7 @@ Expect Syntax Error: "conformance/expressions/binaryOperators/comparisonOperator Expect Syntax Error: "conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts" Expect Syntax Error: "conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts" Expect Syntax Error: "conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts" +Expect Syntax Error: "conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidOperands.es2015.ts" Expect Syntax Error: "conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidOperands.ts" Expect Syntax Error: "conformance/expressions/binaryOperators/logicalAndOperator/logicalAndOperatorStrictMode.ts" Expect Syntax Error: "conformance/expressions/binaryOperators/logicalAndOperator/logicalAndOperatorWithEveryType.ts" @@ -2688,6 +2694,7 @@ Expect Syntax Error: "conformance/expressions/typeGuards/typeGuardsInIfStatement Expect Syntax Error: "conformance/expressions/typeGuards/typeGuardsWithAny.ts" Expect Syntax Error: "conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts" Expect Syntax Error: "conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts" +Expect Syntax Error: "conformance/expressions/typeGuards/typeGuardsWithInstanceOfBySymbolHasInstance.ts" Expect Syntax Error: "conformance/expressions/typeSatisfaction/typeSatisfaction.ts" Expect Syntax Error: "conformance/expressions/typeSatisfaction/typeSatisfaction_contextualTyping2.ts" Expect Syntax Error: "conformance/expressions/typeSatisfaction/typeSatisfaction_js.ts" @@ -11400,8 +11407,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 12 │ } ╰──── - × Invalid Character ` -` + × Invalid Character ` ` ╭─[conformance/classes/members/privateNames/privateNameHashCharName.ts:2:1] 2 │ 3 │ # @@ -15809,6 +15815,29 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 1 │ import * as f from "./first" assert { ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[conformance/importAttributes/importAttributes4.ts:1:1] + 1 │ import * as f from "./first" with + · ─ + ╰──── + help: Try insert a semicolon here + + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[conformance/importAttributes/importAttributes5.ts:1:1] + 1 │ import * as f from "./first" with { + · ─ + ╰──── + help: Try insert a semicolon here + + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[conformance/importAttributes/importAttributes6.ts:2:1] + 2 │ // @filename: mod.mts + 3 │ import * as thing1 from "./mod.mjs" with { field: 0 }; + · ─ + 4 │ import * as thing2 from "./mod.mjs" with { field: `a` }; + ╰──── + help: Try insert a semicolon here + × The keyword 'interface' is reserved ╭─[conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface05.ts:2:1] 2 │ diff --git a/tasks/coverage/test262 b/tasks/coverage/test262 index 79f087814fb2..be5323459058 160000 --- a/tasks/coverage/test262 +++ b/tasks/coverage/test262 @@ -1 +1 @@ -Subproject commit 79f087814fb2e821619e0a27fc7272f8f2bef317 +Subproject commit be5323459058ed14f33df75096ea51cecde8d422 diff --git a/tasks/coverage/typescript b/tasks/coverage/typescript index 7d9399e353c1..a48cebf65d38 160000 --- a/tasks/coverage/typescript +++ b/tasks/coverage/typescript @@ -1 +1 @@ -Subproject commit 7d9399e353c1b770ab1b5c859c98e014cd3fda03 +Subproject commit a48cebf65d382b224ec014b759cb94d7f8c3f929 diff --git a/tasks/transform_conformance/babel.snap.md b/tasks/transform_conformance/babel.snap.md index f3f28b44091f..14ea69866c0f 100644 --- a/tasks/transform_conformance/babel.snap.md +++ b/tasks/transform_conformance/babel.snap.md @@ -1,4 +1,4 @@ -Passed: 86/1092 +Passed: 87/1106 # babel-plugin-transform-class-properties * Failed: assumption-constantSuper/complex-super-class/input.js @@ -530,6 +530,12 @@ Passed: 86/1092 * Failed: amd/script/input.js * Failed: amd/to-string/input.js * Failed: amd/with-other-import-export/input.mjs +* Failed: amd-createImportExpression-false/missing-plugin/input.mjs +* Failed: amd-createImportExpression-false/module/input.mjs +* Failed: amd-createImportExpression-false/no-interop/input.js +* Failed: amd-createImportExpression-false/script/input.js +* Failed: amd-createImportExpression-false/to-string/input.js +* Failed: amd-createImportExpression-false/with-other-import-export/input.mjs * Failed: commonjs/missing-plugin/input.mjs * Failed: commonjs/module/input.mjs * Failed: commonjs/no-interop/input.js @@ -537,12 +543,23 @@ Passed: 86/1092 * Failed: commonjs/shadowed-require/input.js * Failed: commonjs/template-literal/input.js * Failed: commonjs/to-string/input.js -* Failed: systemjs/missing-plugin-babel-7/input.mjs +* Failed: commonjs-createImportExpression-false/missing-plugin/input.mjs +* Failed: commonjs-createImportExpression-false/module/input.mjs +* Failed: commonjs-createImportExpression-false/no-interop/input.js +* Failed: commonjs-createImportExpression-false/script/input.js +* Failed: commonjs-createImportExpression-false/shadowed-require/input.js +* Failed: commonjs-createImportExpression-false/template-literal/input.js +* Failed: commonjs-createImportExpression-false/to-string/input.js * Failed: systemjs/module/input.mjs * Failed: systemjs/script/input.js * Failed: systemjs/to-string/input.js +* Failed: systemjs-createImportExpression-false/missing-plugin-babel-7/input.mjs +* Failed: systemjs-createImportExpression-false/module/input.mjs +* Failed: systemjs-createImportExpression-false/script/input.js +* Failed: systemjs-createImportExpression-false/to-string/input.js * Passed: missing-module-transform/missing-module-transform/input.js * Passed: systemjs/missing-plugin/input.mjs +* Passed: systemjs-createImportExpression-false/missing-plugin/input.mjs # babel-plugin-transform-export-namespace-from * Failed: export-namespace/namespace-default/input.mjs @@ -587,9 +604,6 @@ Passed: 86/1092 * Failed: general/in-method-key/input.js * Failed: general/in-method-key-loose/input.js * Failed: general/in-var-destructuring/input.js -* Failed: general/lhs-assignment/input.js -* Failed: general/lhs-assignment-read-and-update/input.js -* Failed: general/lhs-update/input.js * Failed: general/member-access/input.js * Failed: general/memoize/input.js * Failed: general/memoize-loose/input.js From b1b2ae57fe600c27f967e87adf1837abc83bfd5d Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Sat, 30 Sep 2023 10:35:47 +0100 Subject: [PATCH 18/23] feedback --- .gitignore | 3 --- crates/oxc_parser/src/js/declaration.rs | 1 + crates/oxc_parser/src/js/statement.rs | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3f3db603f48e..611e7592de5b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,3 @@ crates/oxc_napi/*.node /*.jsx /*.ts /*.tsx - -# MacOS -.DS_Store diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index b91ae683d950..a749a6bd2f30 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -111,6 +111,7 @@ impl<'a> Parser<'a> { Ok(self.ast.variable_declarator(self.end_span(span), kind, id, init, definite)) } + /// Section 14.3.1 Let, Const, and Using Declarations /// UsingDeclaration[In, Yield, Await] : /// using [no LineTerminator here] [lookahead ≠ await] BindingList[?In, ?Yield, ?Await, ~Pattern] ; pub(crate) fn parse_using_declaration( diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index 5d4ba9a82a0c..8e00f44ae1e3 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -122,8 +122,6 @@ impl<'a> Parser<'a> { self.parse_variable_statement(stmt_ctx) } Kind::Let if !self.cur_token().escaped => self.parse_let(stmt_ctx), - // TODO: investigate whether we can get better error messages by not checking `self.nth_kind(2).is_binding_identifier()` - // and instead attempting to parse the using declaration and then checking if it is valid. Kind::Await if self.peek_kind() == Kind::Using && self.nth_kind(2).is_binding_identifier() => { From 5dd942318741c97b714ce61f62a3828cc2126bfd Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Wed, 4 Oct 2023 10:30:23 +0100 Subject: [PATCH 19/23] suggestions + just sync --- crates/oxc_parser/src/js/declaration.rs | 2 +- tasks/coverage/formatter_test262.snap | 4 ++-- tasks/coverage/parser_test262.snap | 4 ++-- tasks/coverage/parser_typescript.snap | 4 ++-- tasks/coverage/test262 | 2 +- tasks/coverage/typescript | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index a749a6bd2f30..4db87c6d04fb 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -45,7 +45,7 @@ impl<'a> Parser<'a> { pub(crate) fn parse_using(&mut self) -> Result> { let using_decl = self.parse_using_declaration(StatementContext::StatementList)?; - self.expect(Kind::Semicolon)?; + self.asi()?; Ok(Statement::Declaration(Declaration::UsingDeclaration(self.ast.alloc(using_decl)))) } diff --git a/tasks/coverage/formatter_test262.snap b/tasks/coverage/formatter_test262.snap index f185ed00ea45..69413fed8872 100644 --- a/tasks/coverage/formatter_test262.snap +++ b/tasks/coverage/formatter_test262.snap @@ -1,3 +1,3 @@ formatter_test262 Summary: -AST Parsed : 45485/45485 (100.00%) -Positive Passed: 45485/45485 (100.00%) +AST Parsed : 45488/45488 (100.00%) +Positive Passed: 45488/45488 (100.00%) diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index fe681ff97894..121f7c776137 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -1,6 +1,6 @@ parser_test262 Summary: -AST Parsed : 44961/44961 (100.00%) -Positive Passed: 44961/44961 (100.00%) +AST Parsed : 44964/44964 (100.00%) +Positive Passed: 44964/44964 (100.00%) Negative Passed: 3919/3947 (99.29%) Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-01.js" Expect Syntax Error: "built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-02.js" diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index c7bde3642c1e..cf222048505f 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -1,6 +1,6 @@ parser_typescript Summary: -AST Parsed : 5166/5170 (99.92%) -Positive Passed: 5158/5170 (99.77%) +AST Parsed : 5167/5171 (99.92%) +Positive Passed: 5159/5171 (99.77%) Negative Passed: 1023/4841 (21.13%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" diff --git a/tasks/coverage/test262 b/tasks/coverage/test262 index be5323459058..47eb8dd68506 160000 --- a/tasks/coverage/test262 +++ b/tasks/coverage/test262 @@ -1 +1 @@ -Subproject commit be5323459058ed14f33df75096ea51cecde8d422 +Subproject commit 47eb8dd68506eeced55e5b8636b2f4636305dbc1 diff --git a/tasks/coverage/typescript b/tasks/coverage/typescript index a48cebf65d38..375216469400 160000 --- a/tasks/coverage/typescript +++ b/tasks/coverage/typescript @@ -1 +1 @@ -Subproject commit a48cebf65d382b224ec014b759cb94d7f8c3f929 +Subproject commit 375216469400fab44cbcec99e7d14eb8f96fd059 From 0d33e83b0232ac466e22a27c961b9acce3bc0f4f Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Wed, 4 Oct 2023 12:17:53 +0100 Subject: [PATCH 20/23] extract to fn --- crates/oxc_parser/src/js/statement.rs | 86 ++++++++++++++++----------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index 8e00f44ae1e3..b04645054be2 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -259,46 +259,13 @@ impl<'a> Parser<'a> { || self.at(Kind::Var) || (self.at(Kind::Let) && self.peek_kind().is_after_let()) { - let start_span = self.start_span(); - let init_declaration = self.without_context(Context::In, |p| { - let decl_ctx = VariableDeclarationContext::new(VariableDeclarationParent::For); - p.parse_variable_declaration(start_span, decl_ctx, Modifiers::empty()) - })?; - - // for (.. a in) for (.. a of) - if matches!(self.cur_kind(), Kind::In | Kind::Of) { - let init = ForStatementLeft::VariableDeclaration(init_declaration); - return self.parse_for_in_or_of_loop(span, r#await, init); - } - - let init = Some(ForStatementInit::VariableDeclaration(init_declaration)); - return self.parse_for_loop(span, init, r#await); + return self.parse_variable_declaration_for_statement(span, r#await); } if (self.cur_kind() == Kind::Await && self.peek_kind() == Kind::Using) || (self.cur_kind() == Kind::Using && self.peek_kind() == Kind::Ident) { - let using_decl = self.parse_using_declaration(StatementContext::For)?; - - if matches!(self.cur_kind(), Kind::In) { - if using_decl.is_await { - self.error(diagnostics::AwaitUsingDeclarationNotAllowedInForInStatement( - using_decl.span, - )); - } else { - self.error(diagnostics::UsingDeclarationNotAllowedInForInStatement( - using_decl.span, - )); - } - } - - if matches!(self.cur_kind(), Kind::In | Kind::Of) { - let init = ForStatementLeft::UsingDeclaration(self.ast.alloc(using_decl)); - return self.parse_for_in_or_of_loop(span, r#await, init); - } - - let init = Some(ForStatementInit::UsingDeclaration(self.ast.alloc(using_decl))); - return self.parse_for_loop(span, init, r#await); + return self.parse_using_declaration_for_statement(span, r#await); } let is_let_of = self.at(Kind::Let) && self.peek_at(Kind::Of); @@ -329,6 +296,55 @@ impl<'a> Parser<'a> { self.parse_for_loop(span, Some(ForStatementInit::Expression(init_expression)), r#await) } + fn parse_variable_declaration_for_statement( + &mut self, + span: Span, + r#await: bool, + ) -> Result> { + let start_span = self.start_span(); + let init_declaration = self.without_context(Context::In, |p| { + let decl_ctx = VariableDeclarationContext::new(VariableDeclarationParent::For); + p.parse_variable_declaration(start_span, decl_ctx, Modifiers::empty()) + })?; + + // for (.. a in) for (.. a of) + if matches!(self.cur_kind(), Kind::In | Kind::Of) { + let init = ForStatementLeft::VariableDeclaration(init_declaration); + return self.parse_for_in_or_of_loop(span, r#await, init); + } + + let init = Some(ForStatementInit::VariableDeclaration(init_declaration)); + self.parse_for_loop(span, init, r#await) + } + + fn parse_using_declaration_for_statement( + &mut self, + span: Span, + r#await: bool, + ) -> Result> { + let using_decl = self.parse_using_declaration(StatementContext::For)?; + + if matches!(self.cur_kind(), Kind::In) { + if using_decl.is_await { + self.error(diagnostics::AwaitUsingDeclarationNotAllowedInForInStatement( + using_decl.span, + )); + } else { + self.error(diagnostics::UsingDeclarationNotAllowedInForInStatement( + using_decl.span, + )); + } + } + + if matches!(self.cur_kind(), Kind::In | Kind::Of) { + let init = ForStatementLeft::UsingDeclaration(self.ast.alloc(using_decl)); + return self.parse_for_in_or_of_loop(span, r#await, init); + } + + let init = Some(ForStatementInit::UsingDeclaration(self.ast.alloc(using_decl))); + self.parse_for_loop(span, init, r#await) + } + fn parse_for_loop( &mut self, span: Span, From 0d78df6ec3e5e3093ebd643c996ee10a00ad57ba Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Wed, 4 Oct 2023 12:18:37 +0100 Subject: [PATCH 21/23] add doc --- crates/oxc_ast/src/ast/js.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index bd68568be59c..aefdf6843f6d 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1070,6 +1070,7 @@ pub struct VariableDeclarator<'a> { pub definite: bool, } +/// https://github.com/tc39/proposal-explicit-resource-management #[derive(Debug, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))] pub struct UsingDeclaration<'a> { From c14e5b17330bec54f5e583599c8c4a5791c39304 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Wed, 4 Oct 2023 12:40:02 +0100 Subject: [PATCH 22/23] doc --- crates/oxc_ast/src/ast/js.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index aefdf6843f6d..43b02978e3d4 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1070,7 +1070,7 @@ pub struct VariableDeclarator<'a> { pub definite: bool, } -/// https://github.com/tc39/proposal-explicit-resource-management +/// #[derive(Debug, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))] pub struct UsingDeclaration<'a> { From b9ab6cd5bd08f088d568152e64bb3b2cab9efadf Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Wed, 4 Oct 2023 12:41:29 +0100 Subject: [PATCH 23/23] doc --- crates/oxc_ast/src/ast/js.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 43b02978e3d4..394ed08cac26 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1070,6 +1070,7 @@ pub struct VariableDeclarator<'a> { pub definite: bool, } +/// Using Declaration /// #[derive(Debug, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]