diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 68ace391b9094..c6fe4cae68c4d 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1590,14 +1590,14 @@ pub struct Class<'a> { #[cfg_attr(feature = "serialize", serde(flatten))] pub span: Span, pub decorators: Vec<'a, Decorator<'a>>, - #[scope(enter_before)] pub id: Option>, + #[scope(enter_before)] + pub type_parameters: Option>>, #[visit_as(ClassHeritage)] pub super_class: Option>, - pub body: Box<'a, ClassBody<'a>>, - pub type_parameters: Option>>, pub super_type_parameters: Option>>, pub implements: Option>>, + pub body: Box<'a, ClassBody<'a>>, pub r#abstract: bool, pub declare: bool, pub scope_id: Cell>, diff --git a/crates/oxc_ast/src/generated/ast_builder.rs b/crates/oxc_ast/src/generated/ast_builder.rs index a254161a27360..5034aef8b361a 100644 --- a/crates/oxc_ast/src/generated/ast_builder.rs +++ b/crates/oxc_ast/src/generated/ast_builder.rs @@ -485,29 +485,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Expression<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { Expression::ClassExpression(self.alloc(self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ))) @@ -2728,29 +2728,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Declaration<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { Declaration::ClassDeclaration(self.alloc(self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ))) @@ -3942,29 +3942,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Class<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { Class { r#type, span, decorators, id, - super_class, - body: body.into_in(self.allocator), type_parameters: type_parameters.into_in(self.allocator), + super_class, super_type_parameters: super_type_parameters.into_in(self.allocator), implements, + body: body.into_in(self.allocator), r#abstract, declare, scope_id: Default::default(), @@ -3978,29 +3978,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Box<'a, Class<'a>> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ) @@ -4943,29 +4943,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> ExportDefaultDeclarationKind<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { ExportDefaultDeclarationKind::ClassDeclaration(self.alloc(self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ))) diff --git a/crates/oxc_ast/src/generated/visit.rs b/crates/oxc_ast/src/generated/visit.rs index fa2697957a008..d1ee257ae5401 100644 --- a/crates/oxc_ast/src/generated/visit.rs +++ b/crates/oxc_ast/src/generated/visit.rs @@ -803,6 +803,16 @@ pub trait Visit<'a>: Sized { walk_class_heritage(self, it); } + #[inline] + fn visit_ts_class_implementses(&mut self, it: &Vec<'a, TSClassImplements<'a>>) { + walk_ts_class_implementses(self, it); + } + + #[inline] + fn visit_ts_class_implements(&mut self, it: &TSClassImplements<'a>) { + walk_ts_class_implements(self, it); + } + #[inline] fn visit_class_body(&mut self, it: &ClassBody<'a>) { walk_class_body(self, it); @@ -843,16 +853,6 @@ pub trait Visit<'a>: Sized { walk_accessor_property(self, it); } - #[inline] - fn visit_ts_class_implementses(&mut self, it: &Vec<'a, TSClassImplements<'a>>) { - walk_ts_class_implementses(self, it); - } - - #[inline] - fn visit_ts_class_implements(&mut self, it: &TSClassImplements<'a>) { - walk_ts_class_implements(self, it); - } - #[inline] fn visit_conditional_expression(&mut self, it: &ConditionalExpression<'a>) { walk_conditional_expression(self, it); @@ -2925,23 +2925,23 @@ pub mod walk { let kind = AstKind::Class(visitor.alloc(it)); visitor.enter_node(kind); visitor.visit_decorators(&it.decorators); - visitor.enter_scope(ScopeFlags::StrictMode, &it.scope_id); if let Some(id) = &it.id { visitor.visit_binding_identifier(id); } - if let Some(super_class) = &it.super_class { - visitor.visit_class_heritage(super_class); - } - visitor.visit_class_body(&it.body); + visitor.enter_scope(ScopeFlags::StrictMode, &it.scope_id); if let Some(type_parameters) = &it.type_parameters { visitor.visit_ts_type_parameter_declaration(type_parameters); } + if let Some(super_class) = &it.super_class { + visitor.visit_class_heritage(super_class); + } if let Some(super_type_parameters) = &it.super_type_parameters { visitor.visit_ts_type_parameter_instantiation(super_type_parameters); } if let Some(implements) = &it.implements { visitor.visit_ts_class_implementses(implements); } + visitor.visit_class_body(&it.body); visitor.leave_node(kind); visitor.leave_scope(); } @@ -2953,6 +2953,27 @@ pub mod walk { visitor.leave_node(kind); } + #[inline] + pub fn walk_ts_class_implementses<'a, V: Visit<'a>>( + visitor: &mut V, + it: &Vec<'a, TSClassImplements<'a>>, + ) { + for el in it.iter() { + visitor.visit_ts_class_implements(el); + } + } + + #[inline] + pub fn walk_ts_class_implements<'a, V: Visit<'a>>(visitor: &mut V, it: &TSClassImplements<'a>) { + let kind = AstKind::TSClassImplements(visitor.alloc(it)); + visitor.enter_node(kind); + visitor.visit_ts_type_name(&it.expression); + if let Some(type_parameters) = &it.type_parameters { + visitor.visit_ts_type_parameter_instantiation(type_parameters); + } + visitor.leave_node(kind); + } + #[inline] pub fn walk_class_body<'a, V: Visit<'a>>(visitor: &mut V, it: &ClassBody<'a>) { let kind = AstKind::ClassBody(visitor.alloc(it)); @@ -3072,27 +3093,6 @@ pub mod walk { } } - #[inline] - pub fn walk_ts_class_implementses<'a, V: Visit<'a>>( - visitor: &mut V, - it: &Vec<'a, TSClassImplements<'a>>, - ) { - for el in it.iter() { - visitor.visit_ts_class_implements(el); - } - } - - #[inline] - pub fn walk_ts_class_implements<'a, V: Visit<'a>>(visitor: &mut V, it: &TSClassImplements<'a>) { - let kind = AstKind::TSClassImplements(visitor.alloc(it)); - visitor.enter_node(kind); - visitor.visit_ts_type_name(&it.expression); - if let Some(type_parameters) = &it.type_parameters { - visitor.visit_ts_type_parameter_instantiation(type_parameters); - } - visitor.leave_node(kind); - } - #[inline] pub fn walk_conditional_expression<'a, V: Visit<'a>>( visitor: &mut V, diff --git a/crates/oxc_ast/src/generated/visit_mut.rs b/crates/oxc_ast/src/generated/visit_mut.rs index 6c89eb0823911..1de9b398859cc 100644 --- a/crates/oxc_ast/src/generated/visit_mut.rs +++ b/crates/oxc_ast/src/generated/visit_mut.rs @@ -795,6 +795,16 @@ pub trait VisitMut<'a>: Sized { walk_class_heritage(self, it); } + #[inline] + fn visit_ts_class_implementses(&mut self, it: &mut Vec<'a, TSClassImplements<'a>>) { + walk_ts_class_implementses(self, it); + } + + #[inline] + fn visit_ts_class_implements(&mut self, it: &mut TSClassImplements<'a>) { + walk_ts_class_implements(self, it); + } + #[inline] fn visit_class_body(&mut self, it: &mut ClassBody<'a>) { walk_class_body(self, it); @@ -835,16 +845,6 @@ pub trait VisitMut<'a>: Sized { walk_accessor_property(self, it); } - #[inline] - fn visit_ts_class_implementses(&mut self, it: &mut Vec<'a, TSClassImplements<'a>>) { - walk_ts_class_implementses(self, it); - } - - #[inline] - fn visit_ts_class_implements(&mut self, it: &mut TSClassImplements<'a>) { - walk_ts_class_implements(self, it); - } - #[inline] fn visit_conditional_expression(&mut self, it: &mut ConditionalExpression<'a>) { walk_conditional_expression(self, it); @@ -3049,23 +3049,23 @@ pub mod walk_mut { let kind = AstType::Class; visitor.enter_node(kind); visitor.visit_decorators(&mut it.decorators); - visitor.enter_scope(ScopeFlags::StrictMode, &it.scope_id); if let Some(id) = &mut it.id { visitor.visit_binding_identifier(id); } - if let Some(super_class) = &mut it.super_class { - visitor.visit_class_heritage(super_class); - } - visitor.visit_class_body(&mut it.body); + visitor.enter_scope(ScopeFlags::StrictMode, &it.scope_id); if let Some(type_parameters) = &mut it.type_parameters { visitor.visit_ts_type_parameter_declaration(type_parameters); } + if let Some(super_class) = &mut it.super_class { + visitor.visit_class_heritage(super_class); + } if let Some(super_type_parameters) = &mut it.super_type_parameters { visitor.visit_ts_type_parameter_instantiation(super_type_parameters); } if let Some(implements) = &mut it.implements { visitor.visit_ts_class_implementses(implements); } + visitor.visit_class_body(&mut it.body); visitor.leave_node(kind); visitor.leave_scope(); } @@ -3077,6 +3077,30 @@ pub mod walk_mut { visitor.leave_node(kind); } + #[inline] + pub fn walk_ts_class_implementses<'a, V: VisitMut<'a>>( + visitor: &mut V, + it: &mut Vec<'a, TSClassImplements<'a>>, + ) { + for el in it.iter_mut() { + visitor.visit_ts_class_implements(el); + } + } + + #[inline] + pub fn walk_ts_class_implements<'a, V: VisitMut<'a>>( + visitor: &mut V, + it: &mut TSClassImplements<'a>, + ) { + let kind = AstType::TSClassImplements; + visitor.enter_node(kind); + visitor.visit_ts_type_name(&mut it.expression); + if let Some(type_parameters) = &mut it.type_parameters { + visitor.visit_ts_type_parameter_instantiation(type_parameters); + } + visitor.leave_node(kind); + } + #[inline] pub fn walk_class_body<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut ClassBody<'a>) { let kind = AstType::ClassBody; @@ -3205,30 +3229,6 @@ pub mod walk_mut { } } - #[inline] - pub fn walk_ts_class_implementses<'a, V: VisitMut<'a>>( - visitor: &mut V, - it: &mut Vec<'a, TSClassImplements<'a>>, - ) { - for el in it.iter_mut() { - visitor.visit_ts_class_implements(el); - } - } - - #[inline] - pub fn walk_ts_class_implements<'a, V: VisitMut<'a>>( - visitor: &mut V, - it: &mut TSClassImplements<'a>, - ) { - let kind = AstType::TSClassImplements; - visitor.enter_node(kind); - visitor.visit_ts_type_name(&mut it.expression); - if let Some(type_parameters) = &mut it.type_parameters { - visitor.visit_ts_type_parameter_instantiation(type_parameters); - } - visitor.leave_node(kind); - } - #[inline] pub fn walk_conditional_expression<'a, V: VisitMut<'a>>( visitor: &mut V, diff --git a/crates/oxc_isolated_declarations/src/class.rs b/crates/oxc_isolated_declarations/src/class.rs index 7c93e6f7300fd..20ef7f00915d8 100644 --- a/crates/oxc_isolated_declarations/src/class.rs +++ b/crates/oxc_isolated_declarations/src/class.rs @@ -490,11 +490,11 @@ impl<'a> IsolatedDeclarations<'a> { decl.span, self.ast.vec(), self.ast.copy(&decl.id), - self.ast.copy(&decl.super_class), - body, self.ast.copy(&decl.type_parameters), + self.ast.copy(&decl.super_class), self.ast.copy(&decl.super_type_parameters), self.ast.copy(&decl.implements), + body, decl.r#abstract, declare.unwrap_or_else(|| self.is_declare()), )) diff --git a/crates/oxc_parser/src/js/class.rs b/crates/oxc_parser/src/js/class.rs index 77ab8288b3369..f606af61cf96a 100644 --- a/crates/oxc_parser/src/js/class.rs +++ b/crates/oxc_parser/src/js/class.rs @@ -99,11 +99,11 @@ impl<'a> ParserImpl<'a> { self.end_span(start_span), decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, modifiers.contains_abstract(), modifiers.contains_declare(), )) diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 5fcb1ef40e0b3..6c88afd50d23f 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -1442,46 +1442,6 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> { self.leave_scope(); } - fn visit_class(&mut self, class: &Class<'a>) { - // Class level decorators are transpiled as functions outside of the class taking the class - // itself as argument. They should be visited before class is entered. E.g., they inherit - // strict mode from the enclosing scope rather than from class. - for decorator in &class.decorators { - self.visit_decorator(decorator); - } - let kind = AstKind::Class(self.alloc(class)); - - // FIXME(don): Should we enter a scope when visiting class declarations? - let is_class_expr = class.r#type == ClassType::ClassExpression; - if is_class_expr { - // Class expressions create a temporary scope with the class name as its only variable - // E.g., `let c = class A { foo() { console.log(A) } }` - self.enter_scope(ScopeFlags::empty(), &class.scope_id); - } - - self.enter_node(kind); - - if let Some(id) = &class.id { - self.visit_binding_identifier(id); - } - if let Some(parameters) = &class.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); - } - - if let Some(super_class) = &class.super_class { - self.visit_class_heritage(super_class); - } - if let Some(super_parameters) = &class.super_type_parameters { - self.visit_ts_type_parameter_instantiation(super_parameters); - } - self.visit_class_body(&class.body); - - self.leave_node(kind); - if is_class_expr { - self.leave_scope(); - } - } - fn visit_arrow_function_expression(&mut self, expr: &ArrowFunctionExpression<'a>) { let kind = AstKind::ArrowFunctionExpression(self.alloc(expr)); self.enter_scope(ScopeFlags::Function | ScopeFlags::Arrow, &expr.scope_id); diff --git a/crates/oxc_traverse/src/ancestor.rs b/crates/oxc_traverse/src/ancestor.rs index 02f78af89c23e..e79b91ef385d1 100644 --- a/crates/oxc_traverse/src/ancestor.rs +++ b/crates/oxc_traverse/src/ancestor.rs @@ -158,11 +158,11 @@ pub(crate) enum AncestorType { YieldExpressionArgument = 126, ClassDecorators = 127, ClassId = 128, - ClassSuperClass = 129, - ClassBody = 130, - ClassTypeParameters = 131, - ClassSuperTypeParameters = 132, - ClassImplements = 133, + ClassTypeParameters = 129, + ClassSuperClass = 130, + ClassSuperTypeParameters = 131, + ClassImplements = 132, + ClassBody = 133, ClassBodyBody = 134, MethodDefinitionDecorators = 135, MethodDefinitionKey = 136, @@ -557,12 +557,12 @@ pub enum Ancestor<'a> { AncestorType::YieldExpressionArgument as u16, ClassDecorators(ClassWithoutDecorators<'a>) = AncestorType::ClassDecorators as u16, ClassId(ClassWithoutId<'a>) = AncestorType::ClassId as u16, - ClassSuperClass(ClassWithoutSuperClass<'a>) = AncestorType::ClassSuperClass as u16, - ClassBody(ClassWithoutBody<'a>) = AncestorType::ClassBody as u16, ClassTypeParameters(ClassWithoutTypeParameters<'a>) = AncestorType::ClassTypeParameters as u16, + ClassSuperClass(ClassWithoutSuperClass<'a>) = AncestorType::ClassSuperClass as u16, ClassSuperTypeParameters(ClassWithoutSuperTypeParameters<'a>) = AncestorType::ClassSuperTypeParameters as u16, ClassImplements(ClassWithoutImplements<'a>) = AncestorType::ClassImplements as u16, + ClassBody(ClassWithoutBody<'a>) = AncestorType::ClassBody as u16, ClassBodyBody(ClassBodyWithoutBody<'a>) = AncestorType::ClassBodyBody as u16, MethodDefinitionDecorators(MethodDefinitionWithoutDecorators<'a>) = AncestorType::MethodDefinitionDecorators as u16, @@ -1284,11 +1284,11 @@ impl<'a> Ancestor<'a> { self, Self::ClassDecorators(_) | Self::ClassId(_) - | Self::ClassSuperClass(_) - | Self::ClassBody(_) | Self::ClassTypeParameters(_) + | Self::ClassSuperClass(_) | Self::ClassSuperTypeParameters(_) | Self::ClassImplements(_) + | Self::ClassBody(_) ) } @@ -6135,12 +6135,12 @@ pub(crate) const OFFSET_CLASS_TYPE: usize = offset_of!(Class, r#type); pub(crate) const OFFSET_CLASS_SPAN: usize = offset_of!(Class, span); pub(crate) const OFFSET_CLASS_DECORATORS: usize = offset_of!(Class, decorators); pub(crate) const OFFSET_CLASS_ID: usize = offset_of!(Class, id); -pub(crate) const OFFSET_CLASS_SUPER_CLASS: usize = offset_of!(Class, super_class); -pub(crate) const OFFSET_CLASS_BODY: usize = offset_of!(Class, body); pub(crate) const OFFSET_CLASS_TYPE_PARAMETERS: usize = offset_of!(Class, type_parameters); +pub(crate) const OFFSET_CLASS_SUPER_CLASS: usize = offset_of!(Class, super_class); pub(crate) const OFFSET_CLASS_SUPER_TYPE_PARAMETERS: usize = offset_of!(Class, super_type_parameters); pub(crate) const OFFSET_CLASS_IMPLEMENTS: usize = offset_of!(Class, implements); +pub(crate) const OFFSET_CLASS_BODY: usize = offset_of!(Class, body); pub(crate) const OFFSET_CLASS_ABSTRACT: usize = offset_of!(Class, r#abstract); pub(crate) const OFFSET_CLASS_DECLARE: usize = offset_of!(Class, declare); pub(crate) const OFFSET_CLASS_SCOPE_ID: usize = offset_of!(Class, scope_id); @@ -6168,22 +6168,17 @@ impl<'a> ClassWithoutDecorators<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6203,6 +6198,11 @@ impl<'a> ClassWithoutDecorators<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6244,22 +6244,17 @@ impl<'a> ClassWithoutId<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6279,6 +6274,11 @@ impl<'a> ClassWithoutId<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6299,9 +6299,9 @@ impl<'a> ClassWithoutId<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutSuperClass<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutTypeParameters<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutSuperClass<'a> { +impl<'a> ClassWithoutTypeParameters<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6327,15 +6327,9 @@ impl<'a> ClassWithoutSuperClass<'a> { } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6355,6 +6349,11 @@ impl<'a> ClassWithoutSuperClass<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6375,9 +6374,9 @@ impl<'a> ClassWithoutSuperClass<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutBody<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutSuperClass<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutBody<'a> { +impl<'a> ClassWithoutSuperClass<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6402,13 +6401,6 @@ impl<'a> ClassWithoutBody<'a> { } } - #[inline] - pub fn super_class(&self) -> &Option> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) - } - } - #[inline] pub fn type_parameters(&self) -> &Option>> { unsafe { @@ -6433,6 +6425,11 @@ impl<'a> ClassWithoutBody<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6453,9 +6450,9 @@ impl<'a> ClassWithoutBody<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutTypeParameters<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutSuperTypeParameters<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutTypeParameters<'a> { +impl<'a> ClassWithoutSuperTypeParameters<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6481,22 +6478,17 @@ impl<'a> ClassWithoutTypeParameters<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn super_type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6508,6 +6500,11 @@ impl<'a> ClassWithoutTypeParameters<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6528,9 +6525,9 @@ impl<'a> ClassWithoutTypeParameters<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutSuperTypeParameters<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutImplements<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutSuperTypeParameters<'a> { +impl<'a> ClassWithoutImplements<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6556,31 +6553,31 @@ impl<'a> ClassWithoutSuperTypeParameters<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } } #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn implements(&self) -> &Option>> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) - as *const Option>>) - } + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } } #[inline] @@ -6603,9 +6600,9 @@ impl<'a> ClassWithoutSuperTypeParameters<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutImplements<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutBody<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutImplements<'a> { +impl<'a> ClassWithoutBody<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6631,22 +6628,17 @@ impl<'a> ClassWithoutImplements<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6658,6 +6650,14 @@ impl<'a> ClassWithoutImplements<'a> { } } + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } diff --git a/crates/oxc_traverse/src/walk.rs b/crates/oxc_traverse/src/walk.rs index 9361a1aa78dda..8f6f9174a0fc8 100644 --- a/crates/oxc_traverse/src/walk.rs +++ b/crates/oxc_traverse/src/walk.rs @@ -2459,6 +2459,12 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>( { walk_decorator(traverser, item as *mut _, ctx); } + if let Some(field) = + &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_ID) as *mut Option) + { + ctx.retag_stack(AncestorType::ClassId); + walk_binding_identifier(traverser, field as *mut _, ctx); + } let mut previous_scope_id = None; if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_CLASS_SCOPE_ID) as *mut Cell>)) @@ -2467,11 +2473,11 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>( previous_scope_id = Some(ctx.current_scope_id()); ctx.set_current_scope_id(scope_id); } - if let Some(field) = - &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_ID) as *mut Option) + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_TYPE_PARAMETERS) + as *mut Option>) { - ctx.retag_stack(AncestorType::ClassId); - walk_binding_identifier(traverser, field as *mut _, ctx); + ctx.retag_stack(AncestorType::ClassTypeParameters); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); } if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_CLASS) as *mut Option) @@ -2479,19 +2485,6 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>( ctx.retag_stack(AncestorType::ClassSuperClass); walk_expression(traverser, field as *mut _, ctx); } - ctx.retag_stack(AncestorType::ClassBody); - walk_class_body( - traverser, - (&mut **((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY) as *mut Box)) - as *mut _, - ctx, - ); - if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_TYPE_PARAMETERS) - as *mut Option>) - { - ctx.retag_stack(AncestorType::ClassTypeParameters); - walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); - } if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_TYPE_PARAMETERS) as *mut Option>) { @@ -2506,6 +2499,13 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>( walk_ts_class_implements(traverser, item as *mut _, ctx); } } + ctx.retag_stack(AncestorType::ClassBody); + walk_class_body( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY) as *mut Box)) + as *mut _, + ctx, + ); ctx.pop_stack(); if let Some(previous_scope_id) = previous_scope_id { ctx.set_current_scope_id(previous_scope_id); diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index 214a54144fb7c..b4366765b60a0 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -2,12 +2,186 @@ commit: a1587416 parser_test262 Summary: AST Parsed : 45859/45859 (100.00%) -Positive Passed: 45859/45859 (100.00%) +Positive Passed: 45845/45859 (99.97%) Negative Passed: 3925/3929 (99.90%) Expect Syntax Error: "language/import/import-assertions/json-invalid.js" Expect Syntax Error: "language/import/import-assertions/json-named-bindings.js" Expect Syntax Error: "language/import/import-attributes/json-invalid.js" Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" +Expect to Parse: "built-ins/Function/prototype/toString/class-expression-explicit-ctor.js" + + × Identifier `A` has already been declared + ╭─[built-ins/Function/prototype/toString/class-expression-explicit-ctor.js:10:5] + 9 │ + 10 │ let A = /* before */class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }/* after */; + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `A` has already been declared here + 11 │ + ╰──── +Expect to Parse: "built-ins/Function/prototype/toString/class-expression-implicit-ctor.js" + + × Identifier `A` has already been declared + ╭─[built-ins/Function/prototype/toString/class-expression-implicit-ctor.js:10:5] + 9 │ + 10 │ let A = /* before */class /* a */ A /* b */ { /* c */ }/* after */; + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `A` has already been declared here + 11 │ let B = /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */; + ╰──── + + × Identifier `B` has already been declared + ╭─[built-ins/Function/prototype/toString/class-expression-implicit-ctor.js:11:5] + 10 │ let A = /* before */class /* a */ A /* b */ { /* c */ }/* after */; + 11 │ let B = /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */; + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `B` has already been declared here + 12 │ let C = /* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */; + ╰──── + + × Identifier `C` has already been declared + ╭─[built-ins/Function/prototype/toString/class-expression-implicit-ctor.js:12:5] + 11 │ let B = /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */; + 12 │ let C = /* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */; + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `C` has already been declared here + 13 │ + ╰──── +Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/expressions/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js:44:10] + 43 │ + 44 │ var C = @yield() class {}; + · ───── + ╰──── +Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/expressions/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js:33:10] + 32 │ + 33 │ var C = @yield class {}; + · ───── + ╰──── +Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/expressions/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js:51:11] + 50 │ + 51 │ var C = @(yield) class {}; + · ───── + ╰──── +Expect to Parse: "language/expressions/class/name.js" + + × Identifier `cls` has already been declared + ╭─[language/expressions/class/name.js:44:22] + 43 │ + 44 │ verifyProperty(class cls {}, "name", { + · ─┬─ + · ╰── `cls` has already been declared here + 45 │ value: "cls", writable: false, enumerable: false, configurable: true + 46 │ }); + 47 │ + 48 │ verifyProperty(class { constructor() {} }, "name", { + 49 │ value: "", writable: false, enumerable: false, configurable: true + 50 │ }); + 51 │ + 52 │ verifyProperty(class cls { constructor() {} }, "name", { + · ─┬─ + · ╰── It can not be redeclared here + 53 │ value: "cls", writable: false, enumerable: false, configurable: true + ╰──── +Expect to Parse: "language/expressions/class/scope-name-lex-close.js" + + × Identifier `C` has already been declared + ╭─[language/expressions/class/scope-name-lex-close.js:12:5] + 11 │ + 12 │ var C = 'outside'; + · ┬ + · ╰── `C` has already been declared here + 13 │ + 14 │ var cls = class C { + · ┬ + · ╰── It can not be redeclared here + 15 │ method() { + ╰──── +Expect to Parse: "language/expressions/class/scope-name-lex-open-heritage.js" + + × Identifier `C` has already been declared + ╭─[language/expressions/class/scope-name-lex-open-heritage.js:22:5] + 21 │ var probeHeritage, setHeritage; + 22 │ var C = 'outside'; + · ┬ + · ╰── `C` has already been declared here + 23 │ + 24 │ var cls = class C extends ( + · ┬ + · ╰── It can not be redeclared here + 25 │ probeHeritage = function() { return C; }, + ╰──── +Expect to Parse: "language/expressions/class/scope-name-lex-open-no-heritage.js" + + × Identifier `C` has already been declared + ╭─[language/expressions/class/scope-name-lex-open-no-heritage.js:23:5] + 22 │ var probeBefore = function() { return C; }; + 23 │ var C = 'outside'; + · ┬ + · ╰── `C` has already been declared here + 24 │ + 25 │ var cls = class C { + · ┬ + · ╰── It can not be redeclared here + 26 │ probe() { + ╰──── +Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js:45:2] + 44 │ + 45 │ @yield() class C {} + · ───── + ╰──── +Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js:34:2] + 33 │ + 34 │ @yield class C {} + · ───── + ╰──── +Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js:52:3] + 51 │ + 52 │ @(yield) class C {} + · ───── + ╰──── +Expect to Parse: "language/statements/class/definition/basics.js" + + × Identifier `C` has already been declared + ╭─[language/statements/class/definition/basics.js:8:5] + 7 │ ---*/ + 8 │ var C = class C {} + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `C` has already been declared here + 9 │ assert.sameValue(typeof C, 'function', "`typeof C` is `'function'`"); + ╰──── +Expect to Parse: "language/statements/class/name-binding/in-extends-expression-assigned.js" + + × Identifier `x` has already been declared + ╭─[language/statements/class/name-binding/in-extends-expression-assigned.js:9:7] + 8 │ assert.throws(ReferenceError, function() { + 9 │ var x = (class x extends x {}); + · ┬ ┬ + · │ ╰── It can not be redeclared here + · ╰── `x` has already been declared here + 10 │ }); + ╰──── × '0'-prefixed octal literals and octal escape sequences are deprecated ╭─[annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict.js:18:4] @@ -12629,6 +12803,14 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" × Cannot use `await` as an identifier in an async context ╭─[language/expressions/class/static-init-await-binding.js:21:12] 20 │ static { + 21 │ (class await {}); + · ───── + 22 │ } + ╰──── + + × Cannot use await in class static initialization block + ╭─[language/expressions/class/static-init-await-binding.js:21:12] + 20 │ static { 21 │ (class await {}); · ───── 22 │ } diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 2f46024cd6191..70ea9ce1cfc20 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -2,8 +2,8 @@ commit: d8086f14 parser_typescript Summary: AST Parsed : 5279/5283 (99.92%) -Positive Passed: 5271/5283 (99.77%) -Negative Passed: 1094/4875 (22.44%) +Positive Passed: 5268/5283 (99.72%) +Negative Passed: 1096/4875 (22.48%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -2565,14 +2565,12 @@ Expect Syntax Error: "conformance/es7/exponentiationOperator/exponentiationOpera Expect Syntax Error: "conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts" Expect Syntax Error: "conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts" Expect Syntax Error: "conformance/esDecorators/classDeclaration/accessors/esDecorators-classDeclaration-accessors-nonStaticAbstract.ts" -Expect Syntax Error: "conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-parameterDecorators.ts" Expect Syntax Error: "conformance/esDecorators/classDeclaration/fields/esDecorators-classDeclaration-fields-nonStaticAbstract.ts" Expect Syntax Error: "conformance/esDecorators/classDeclaration/fields/esDecorators-classDeclaration-fields-nonStaticAbstractAccessor.ts" Expect Syntax Error: "conformance/esDecorators/classDeclaration/fields/esDecorators-classDeclaration-fields-nonStaticAmbient.ts" Expect Syntax Error: "conformance/esDecorators/classDeclaration/fields/esDecorators-classDeclaration-fields-staticAmbient.ts" Expect Syntax Error: "conformance/esDecorators/classDeclaration/methods/esDecorators-classDeclaration-methods-nonStaticAbstract.ts" Expect Syntax Error: "conformance/esDecorators/esDecorators-arguments.ts" -Expect Syntax Error: "conformance/esDecorators/esDecorators-emitDecoratorMetadata.ts" Expect Syntax Error: "conformance/expressions/arrayLiterals/arrayLiterals.ts" Expect Syntax Error: "conformance/expressions/arrayLiterals/arrayLiterals3.ts" Expect Syntax Error: "conformance/expressions/asOperator/asOperator2.ts" @@ -3801,6 +3799,21 @@ Expect to Parse: "compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts" · ──── 24 │ const enum H {} ╰──── +Expect to Parse: "compiler/mixinIntersectionIsValidbaseType.ts" + + × Identifier `A` has already been declared + ╭─[compiler/mixinIntersectionIsValidbaseType.ts:22:29] + 21 │ const AMixin = & Initable>(SuperClass: K) => { + 22 │ let SomeHowOkay = class A extends SuperClass { + · ┬ + · ╰── `A` has already been declared here + 23 │ }; + 24 │ + 25 │ let SomeHowNotOkay = class A extends Serializable(SuperClass) { + · ┬ + · ╰── It can not be redeclared here + 26 │ }; + ╰──── Expect to Parse: "compiler/sourceMapValidationDecorators.ts" × Unexpected token @@ -3831,6 +3844,21 @@ Expect to Parse: "conformance/async/es6/asyncWithVarShadowing_es6.ts" · ╰── It can not be redeclared here 132 │ } ╰──── +Expect to Parse: "conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty8.ts" + + × Identifier `Base` has already been declared + ╭─[conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty8.ts:14:7] + 13 │ + 14 │ const Base = classWithProperties({ + · ──┬─ + · ╰── `Base` has already been declared here + 15 │ get x() { return 'boolean' as const }, + 16 │ y: 'string', + 17 │ }, class Base { + · ──┬─ + · ╰── It can not be redeclared here + 18 │ }); + ╰──── Expect to Parse: "conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts" × Classes may not have a static property named prototype @@ -3899,6 +3927,18 @@ Expect to Parse: "conformance/es6/moduleExportsSystem/topLevelVarHoistingCommonJ · ──── 65 │ var y = _; ╰──── +Expect to Parse: "conformance/esDecorators/classExpression/namedEvaluation/esDecorators-classExpression-namedEvaluation.11.ts" + + × Identifier `C` has already been declared + ╭─[conformance/esDecorators/classExpression/namedEvaluation/esDecorators-classExpression-namedEvaluation.11.ts:10:13] + 9 │ + 10 │ (@dec class C {}); + · ┬ + · ╰── `C` has already been declared here + 11 │ (class C { @dec y: any }); + · ┬ + · ╰── It can not be redeclared here + ╰──── Expect to Parse: "conformance/esDecorators/esDecorators-decoratorExpression.1.ts" × Expected a semicolon or an implicit semicolon after a statement, but found none @@ -9479,6 +9519,24 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 14 │ ╰──── + × Identifier `package` has already been declared + ╭─[compiler/strictModeReservedWord.ts:8:9] + 7 │ let let = "blah"; + 8 │ var package = "hello" + · ───┬─── + · ╰── `package` has already been declared here + 9 │ function package() { } + 10 │ function bar(private, implements, let) { } + 11 │ function baz() { } + 12 │ function barn(cb: (private, public, package) => void) { } + 13 │ barn((private, public, package) => { }); + 14 │ + 15 │ var myClass = class package extends public {} + · ───┬─── + · ╰── It can not be redeclared here + 16 │ + ╰──── + × The keyword 'package' is reserved ╭─[compiler/strictModeReservedWord.ts:15:25] 14 │ @@ -9735,6 +9793,30 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 22 │ ╰──── + × The keyword 'public' is reserved + ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:23:20] + 22 │ + 23 │ class E implements public { } + · ────── + 24 │ + ╰──── + + × The keyword 'public' is reserved + ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:25:20] + 24 │ + 25 │ class F implements public.private.B { } + · ────── + 26 │ class F1 implements public.private.implements { } + ╰──── + + × The keyword 'public' is reserved + ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:26:21] + 25 │ class F implements public.private.B { } + 26 │ class F1 implements public.private.implements { } + · ────── + 27 │ class G extends package { } + ╰──── + × The keyword 'package' is reserved ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:27:17] 26 │ class F1 implements public.private.implements { } @@ -15821,6 +15903,38 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" 3 │ } ╰──── + × Identifier `C` has already been declared + ╭─[conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-parameterDecorators.ts:3:7] + 2 │ + 3 │ class C { + · ┬ + · ╰── `C` has already been declared here + 4 │ constructor(@dec x: any) {} + ╰──── + ╭─[conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-parameterDecorators.ts:11:8] + 10 │ + 11 │ (class C { + · ┬ + · ╰── It can not be redeclared here + 12 │ constructor(@dec x: any) {} + ╰──── + + × Identifier `C` has already been declared + ╭─[conformance/esDecorators/esDecorators-emitDecoratorMetadata.ts:4:7] + 3 │ @dec + 4 │ class C { + · ┬ + · ╰── `C` has already been declared here + 5 │ constructor(x: number) {} + ╰──── + ╭─[conformance/esDecorators/esDecorators-emitDecoratorMetadata.ts:26:13] + 25 │ + 26 │ (@dec class C { + · ┬ + · ╰── It can not be redeclared here + 27 │ constructor(x: number) {} + ╰──── + × Private identifier '#foo' is not allowed outside class bodies ╭─[conformance/esDecorators/esDecorators-privateFieldAccess.ts:3:13] 2 │