diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 2d8733090d2cf..fd207cf18a450 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -365,7 +365,6 @@ pub struct ObjectProperty<'a> { pub kind: PropertyKind, pub key: PropertyKey<'a>, pub value: Expression<'a>, - pub init: Option>, // for `CoverInitializedName` pub method: bool, pub shorthand: bool, pub computed: bool, diff --git a/crates/oxc_ast/src/generated/assert_layouts.rs b/crates/oxc_ast/src/generated/assert_layouts.rs index 46528ae7f6158..0f7bf95a85357 100644 --- a/crates/oxc_ast/src/generated/assert_layouts.rs +++ b/crates/oxc_ast/src/generated/assert_layouts.rs @@ -112,16 +112,15 @@ const _: () = { assert!(size_of::() == 16usize); assert!(align_of::() == 8usize); - assert!(size_of::() == 72usize); + assert!(size_of::() == 56usize); assert!(align_of::() == 8usize); assert!(offset_of!(ObjectProperty, span) == 0usize); assert!(offset_of!(ObjectProperty, kind) == 8usize); assert!(offset_of!(ObjectProperty, key) == 16usize); assert!(offset_of!(ObjectProperty, value) == 32usize); - assert!(offset_of!(ObjectProperty, init) == 48usize); - assert!(offset_of!(ObjectProperty, method) == 64usize); - assert!(offset_of!(ObjectProperty, shorthand) == 65usize); - assert!(offset_of!(ObjectProperty, computed) == 66usize); + assert!(offset_of!(ObjectProperty, method) == 48usize); + assert!(offset_of!(ObjectProperty, shorthand) == 49usize); + assert!(offset_of!(ObjectProperty, computed) == 50usize); assert!(size_of::() == 16usize); assert!(align_of::() == 8usize); @@ -1669,16 +1668,15 @@ const _: () = { assert!(size_of::() == 8usize); assert!(align_of::() == 4usize); - assert!(size_of::() == 40usize); + assert!(size_of::() == 32usize); assert!(align_of::() == 4usize); assert!(offset_of!(ObjectProperty, span) == 0usize); assert!(offset_of!(ObjectProperty, kind) == 8usize); assert!(offset_of!(ObjectProperty, key) == 12usize); assert!(offset_of!(ObjectProperty, value) == 20usize); - assert!(offset_of!(ObjectProperty, init) == 28usize); - assert!(offset_of!(ObjectProperty, method) == 36usize); - assert!(offset_of!(ObjectProperty, shorthand) == 37usize); - assert!(offset_of!(ObjectProperty, computed) == 38usize); + assert!(offset_of!(ObjectProperty, method) == 28usize); + assert!(offset_of!(ObjectProperty, shorthand) == 29usize); + assert!(offset_of!(ObjectProperty, computed) == 30usize); assert!(size_of::() == 8usize); assert!(align_of::() == 4usize); diff --git a/crates/oxc_ast/src/generated/ast_builder.rs b/crates/oxc_ast/src/generated/ast_builder.rs index df455a42bb1c6..dc5fa1f0f26e5 100644 --- a/crates/oxc_ast/src/generated/ast_builder.rs +++ b/crates/oxc_ast/src/generated/ast_builder.rs @@ -1602,7 +1602,6 @@ impl<'a> AstBuilder<'a> { /// - kind /// - key /// - value - /// - init /// - method /// - shorthand /// - computed @@ -1613,15 +1612,12 @@ impl<'a> AstBuilder<'a> { kind: PropertyKind, key: PropertyKey<'a>, value: Expression<'a>, - init: Option>, method: bool, shorthand: bool, computed: bool, ) -> ObjectPropertyKind<'a> { ObjectPropertyKind::ObjectProperty( - self.alloc( - self.object_property(span, kind, key, value, init, method, shorthand, computed), - ), + self.alloc(self.object_property(span, kind, key, value, method, shorthand, computed)), ) } @@ -1650,7 +1646,6 @@ impl<'a> AstBuilder<'a> { /// - kind /// - key /// - value - /// - init /// - method /// - shorthand /// - computed @@ -1661,12 +1656,11 @@ impl<'a> AstBuilder<'a> { kind: PropertyKind, key: PropertyKey<'a>, value: Expression<'a>, - init: Option>, method: bool, shorthand: bool, computed: bool, ) -> ObjectProperty<'a> { - ObjectProperty { span, kind, key, value, init, method, shorthand, computed } + ObjectProperty { span, kind, key, value, method, shorthand, computed } } /// Build an [`ObjectProperty`], and store it in the memory arena. @@ -1678,7 +1672,6 @@ impl<'a> AstBuilder<'a> { /// - kind /// - key /// - value - /// - init /// - method /// - shorthand /// - computed @@ -1689,13 +1682,12 @@ impl<'a> AstBuilder<'a> { kind: PropertyKind, key: PropertyKey<'a>, value: Expression<'a>, - init: Option>, method: bool, shorthand: bool, computed: bool, ) -> Box<'a, ObjectProperty<'a>> { Box::new_in( - self.object_property(span, kind, key, value, init, method, shorthand, computed), + self.object_property(span, kind, key, value, method, shorthand, computed), self.allocator, ) } diff --git a/crates/oxc_ast/src/generated/derive_clone_in.rs b/crates/oxc_ast/src/generated/derive_clone_in.rs index 1f9fe794c2cb4..f55805e8c21a3 100644 --- a/crates/oxc_ast/src/generated/derive_clone_in.rs +++ b/crates/oxc_ast/src/generated/derive_clone_in.rs @@ -463,7 +463,6 @@ impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for ObjectProperty<'old_alloc> kind: CloneIn::clone_in(&self.kind, allocator), key: CloneIn::clone_in(&self.key, allocator), value: CloneIn::clone_in(&self.value, allocator), - init: CloneIn::clone_in(&self.init, allocator), method: CloneIn::clone_in(&self.method, allocator), shorthand: CloneIn::clone_in(&self.shorthand, allocator), computed: CloneIn::clone_in(&self.computed, allocator), diff --git a/crates/oxc_ast/src/generated/derive_content_eq.rs b/crates/oxc_ast/src/generated/derive_content_eq.rs index c3a26b5ce93af..8a5ecf2afc833 100644 --- a/crates/oxc_ast/src/generated/derive_content_eq.rs +++ b/crates/oxc_ast/src/generated/derive_content_eq.rs @@ -518,7 +518,6 @@ impl<'a> ContentEq for ObjectProperty<'a> { ContentEq::content_eq(&self.kind, &other.kind) && ContentEq::content_eq(&self.key, &other.key) && ContentEq::content_eq(&self.value, &other.value) - && ContentEq::content_eq(&self.init, &other.init) && ContentEq::content_eq(&self.method, &other.method) && ContentEq::content_eq(&self.shorthand, &other.shorthand) && ContentEq::content_eq(&self.computed, &other.computed) diff --git a/crates/oxc_ast/src/generated/derive_content_hash.rs b/crates/oxc_ast/src/generated/derive_content_hash.rs index e2245d429aa73..8f8342d5ca4b3 100644 --- a/crates/oxc_ast/src/generated/derive_content_hash.rs +++ b/crates/oxc_ast/src/generated/derive_content_hash.rs @@ -233,7 +233,6 @@ impl<'a> ContentHash for ObjectProperty<'a> { ContentHash::content_hash(&self.kind, state); ContentHash::content_hash(&self.key, state); ContentHash::content_hash(&self.value, state); - ContentHash::content_hash(&self.init, state); ContentHash::content_hash(&self.method, state); ContentHash::content_hash(&self.shorthand, state); ContentHash::content_hash(&self.computed, state); diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index 4bdedc6d61d97..54962b124a687 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -285,7 +285,6 @@ impl<'a> Serialize for ObjectProperty<'a> { map.serialize_entry("kind", &self.kind)?; map.serialize_entry("key", &self.key)?; map.serialize_entry("value", &self.value)?; - map.serialize_entry("init", &self.init)?; map.serialize_entry("method", &self.method)?; map.serialize_entry("shorthand", &self.shorthand)?; map.serialize_entry("computed", &self.computed)?; diff --git a/crates/oxc_ast/src/generated/visit.rs b/crates/oxc_ast/src/generated/visit.rs index 8fc63d5780d9e..aeeb5f8689115 100644 --- a/crates/oxc_ast/src/generated/visit.rs +++ b/crates/oxc_ast/src/generated/visit.rs @@ -3157,9 +3157,6 @@ pub mod walk { visitor.enter_node(kind); visitor.visit_property_key(&it.key); visitor.visit_expression(&it.value); - if let Some(init) = &it.init { - visitor.visit_expression(init); - } visitor.leave_node(kind); } diff --git a/crates/oxc_ast/src/generated/visit_mut.rs b/crates/oxc_ast/src/generated/visit_mut.rs index 182e7bb82e5b5..31f1745c183c4 100644 --- a/crates/oxc_ast/src/generated/visit_mut.rs +++ b/crates/oxc_ast/src/generated/visit_mut.rs @@ -3306,9 +3306,6 @@ pub mod walk_mut { visitor.enter_node(kind); visitor.visit_property_key(&mut it.key); visitor.visit_expression(&mut it.value); - if let Some(init) = &mut it.init { - visitor.visit_expression(init); - } visitor.leave_node(kind); } diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index 67ebcaa1abfcb..8c0d459ba22cc 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -441,6 +441,13 @@ pub fn jsx_element_no_match(span: Span, span1: Span, name: &str) -> OxcDiagnosti .with_labels([span, span1]) } +#[cold] +pub fn cover_initialized_name(span: Span) -> OxcDiagnostic { + OxcDiagnostic::error("Invalid assignment in object literal") +.with_help("Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.") +.with_label(span) +} + // ================================= MODIFIERS ================================= #[cold] diff --git a/crates/oxc_parser/src/js/grammar.rs b/crates/oxc_parser/src/js/grammar.rs index d5aea21892acb..668e61c3fa042 100644 --- a/crates/oxc_parser/src/js/grammar.rs +++ b/crates/oxc_parser/src/js/grammar.rs @@ -157,12 +157,7 @@ impl<'a> CoverGrammar<'a, ObjectProperty<'a>> for AssignmentTargetProperty<'a> { _ => return Err(p.unexpected()), }; // convert `CoverInitializedName` - let init = match property.init { - Some(Expression::AssignmentExpression(assignment_expr)) => { - Some(assignment_expr.unbox().right) - } - _ => None, - }; + let init = p.state.cover_initialized_name.remove(&property.span.start).map(|e| e.right); Ok(p.ast.assignment_target_property_assignment_target_property_identifier( property.span, binding, diff --git a/crates/oxc_parser/src/js/object.rs b/crates/oxc_parser/src/js/object.rs index def9d60aef13d..7dbabf09a71d4 100644 --- a/crates/oxc_parser/src/js/object.rs +++ b/crates/oxc_parser/src/js/object.rs @@ -107,7 +107,6 @@ impl<'a> ParserImpl<'a> { PropertyKind::Init, key, Expression::FunctionExpression(method), - /* init */ None, /* method */ true, /* shorthand */ false, /* computed */ computed, @@ -138,24 +137,22 @@ impl<'a> ParserImpl<'a> { // IdentifierReference ({ foo }) let value = Expression::Identifier(self.alloc(identifier.clone())); // CoverInitializedName ({ foo = bar }) - let init = if self.eat(Kind::Eq) { + if self.eat(Kind::Eq) { let right = self.parse_assignment_expression_or_higher()?; let left = AssignmentTarget::AssignmentTargetIdentifier(self.alloc(identifier)); - Some(self.ast.expression_assignment( + let expr = self.ast.assignment_expression( self.end_span(span), AssignmentOperator::Assign, left, right, - )) - } else { - None - }; + ); + self.state.cover_initialized_name.insert(span.start, expr); + } Ok(self.ast.alloc_object_property( self.end_span(span), PropertyKind::Init, PropertyKey::StaticIdentifier(key), value, - init, /* method */ false, /* shorthand */ true, /* computed */ false, @@ -177,7 +174,6 @@ impl<'a> ParserImpl<'a> { PropertyKind::Init, key, value, - None, /* method */ false, /* shorthand */ false, /* computed */ computed, @@ -233,7 +229,6 @@ impl<'a> ParserImpl<'a> { PropertyKind::Init, key, value, - /* init */ None, /* method */ true, /* shorthand */ false, /* computed */ computed, @@ -253,7 +248,6 @@ impl<'a> ParserImpl<'a> { PropertyKind::Get, key, value, - /* init */ None, /* method */ false, /* shorthand */ false, /* computed */ computed, @@ -273,7 +267,6 @@ impl<'a> ParserImpl<'a> { PropertyKind::Set, key, Expression::FunctionExpression(method), - /* init */ None, /* method */ false, /* shorthand */ false, /* computed */ computed, diff --git a/crates/oxc_parser/src/lib.rs b/crates/oxc_parser/src/lib.rs index 5069224588f06..4d8f7013d368b 100644 --- a/crates/oxc_parser/src/lib.rs +++ b/crates/oxc_parser/src/lib.rs @@ -413,6 +413,8 @@ impl<'a> ParserImpl<'a> { (program, true) } }; + + self.check_unfinished_errors(); let mut errors = vec![]; // only check for `@flow` if the file failed to parse. if !self.lexer.errors.is_empty() || !self.errors.is_empty() { @@ -434,6 +436,7 @@ impl<'a> ParserImpl<'a> { // initialize cur_token and prev_token by moving onto the first token self.bump_any(); let expr = self.parse_expr().map_err(|diagnostic| vec![diagnostic])?; + self.check_unfinished_errors(); let errors = self.lexer.errors.into_iter().chain(self.errors).collect::>(); if !errors.is_empty() { return Err(errors); @@ -492,6 +495,15 @@ impl<'a> ParserImpl<'a> { } } + fn check_unfinished_errors(&mut self) { + use oxc_span::GetSpan; + // PropertyDefinition : cover_initialized_name + // It is a Syntax Error if any source text is matched by this production. + for expr in self.state.cover_initialized_name.values() { + self.errors.push(diagnostics::cover_initialized_name(expr.span())); + } + } + /// Check if source length exceeds MAX_LEN, if the file cannot be parsed. /// Original parsing error is not real - `Lexer::new` substituted "\0" as the source text. fn overlong_error(&self) -> Option { diff --git a/crates/oxc_parser/src/state.rs b/crates/oxc_parser/src/state.rs index ba21c4e978802..bb8e193ce9426 100644 --- a/crates/oxc_parser/src/state.rs +++ b/crates/oxc_parser/src/state.rs @@ -1,9 +1,14 @@ -use oxc_ast::ast::Decorator; -use rustc_hash::FxHashSet; +use rustc_hash::{FxHashMap, FxHashSet}; + +use oxc_ast::ast::{AssignmentExpression, Decorator}; #[derive(Default)] pub struct ParserState<'a> { pub not_parenthesized_arrow: FxHashSet, pub decorators: Vec>, + + /// Temporary storage for `CoverInitializedName` `({ foo = bar })`. + /// Keyed by `ObjectProperty`'s span.start. + pub cover_initialized_name: FxHashMap>, } diff --git a/crates/oxc_semantic/src/checker/javascript.rs b/crates/oxc_semantic/src/checker/javascript.rs index 478265bc8f697..132551e4fb6b3 100644 --- a/crates/oxc_semantic/src/checker/javascript.rs +++ b/crates/oxc_semantic/src/checker/javascript.rs @@ -913,19 +913,7 @@ pub fn check_super<'a>(sup: &Super, node: &AstNode<'a>, ctx: &SemanticBuilder<'a } } -fn cover_initialized_name(span: Span) -> OxcDiagnostic { - OxcDiagnostic::error("Invalid assignment in object literal") -.with_help("Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.") -.with_label(span) -} - pub fn check_object_property(prop: &ObjectProperty, ctx: &SemanticBuilder<'_>) { - // PropertyDefinition : cover_initialized_name - // It is a Syntax Error if any source text is matched by this production. - if let Some(expr) = &prop.init { - ctx.error(cover_initialized_name(expr.span())); - } - if let Expression::FunctionExpression(function) = &prop.value { match prop.kind { PropertyKind::Set => check_setter(function, ctx), diff --git a/crates/oxc_transformer/src/jsx/display_name.rs b/crates/oxc_transformer/src/jsx/display_name.rs index 817886973bbc8..f37b0d1154e7a 100644 --- a/crates/oxc_transformer/src/jsx/display_name.rs +++ b/crates/oxc_transformer/src/jsx/display_name.rs @@ -174,7 +174,6 @@ impl<'a, 'ctx> ReactDisplayName<'a, 'ctx> { PropertyKind::Init, ctx.ast.property_key_identifier_name(SPAN, DISPLAY_NAME), ctx.ast.expression_string_literal(SPAN, name), - None, false, false, false, diff --git a/crates/oxc_transformer/src/jsx/jsx_impl.rs b/crates/oxc_transformer/src/jsx/jsx_impl.rs index 488e4b9518c5f..db972b6b511a4 100644 --- a/crates/oxc_transformer/src/jsx/jsx_impl.rs +++ b/crates/oxc_transformer/src/jsx/jsx_impl.rs @@ -536,7 +536,7 @@ impl<'a, 'ctx> JsxImpl<'a, 'ctx> { let key = Self::get_attribute_name(&attr.name, ctx); let value = self.transform_jsx_attribute_value(attr.value.as_ref(), ctx); let object_property = ctx.ast.object_property_kind_object_property( - attr.span, kind, key, value, None, false, false, false, + attr.span, kind, key, value, false, false, false, ); properties.push(object_property); } @@ -600,7 +600,6 @@ impl<'a, 'ctx> JsxImpl<'a, 'ctx> { PropertyKind::Init, ctx.ast.property_key_identifier_name(SPAN, "children"), value, - None, false, false, false, diff --git a/crates/oxc_transformer/src/jsx/jsx_self.rs b/crates/oxc_transformer/src/jsx/jsx_self.rs index eb462055fed2f..8c90fdfd91dc9 100644 --- a/crates/oxc_transformer/src/jsx/jsx_self.rs +++ b/crates/oxc_transformer/src/jsx/jsx_self.rs @@ -89,8 +89,7 @@ impl<'a, 'ctx> JsxSelf<'a, 'ctx> { let kind = PropertyKind::Init; let key = ctx.ast.property_key_identifier_name(SPAN, SELF); let value = ctx.ast.expression_this(SPAN); - ctx.ast - .object_property_kind_object_property(SPAN, kind, key, value, None, false, false, false) + ctx.ast.object_property_kind_object_property(SPAN, kind, key, value, false, false, false) } pub fn can_add_self_attribute(ctx: &TraverseCtx<'a>) -> bool { diff --git a/crates/oxc_transformer/src/jsx/jsx_source.rs b/crates/oxc_transformer/src/jsx/jsx_source.rs index e1f71aedb0016..950473b35a3e7 100644 --- a/crates/oxc_transformer/src/jsx/jsx_source.rs +++ b/crates/oxc_transformer/src/jsx/jsx_source.rs @@ -92,8 +92,7 @@ impl<'a, 'ctx> JsxSource<'a, 'ctx> { let kind = PropertyKind::Init; let key = ctx.ast.property_key_identifier_name(SPAN, SOURCE); let value = self.get_source_object(line, column, ctx); - ctx.ast - .object_property_kind_object_property(SPAN, kind, key, value, None, false, false, false) + ctx.ast.object_property_kind_object_property(SPAN, kind, key, value, false, false, false) } pub fn report_error(&self, span: Span) { @@ -149,9 +148,8 @@ impl<'a, 'ctx> JsxSource<'a, 'ctx> { let filename = { let key = ctx.ast.property_key_identifier_name(SPAN, "fileName"); let value = self.get_filename_var(ctx).create_read_expression(ctx); - ctx.ast.object_property_kind_object_property( - SPAN, kind, key, value, None, false, false, false, - ) + ctx.ast + .object_property_kind_object_property(SPAN, kind, key, value, false, false, false) }; let line_number = { @@ -162,9 +160,8 @@ impl<'a, 'ctx> JsxSource<'a, 'ctx> { line.to_string(), NumberBase::Decimal, ); - ctx.ast.object_property_kind_object_property( - SPAN, kind, key, value, None, false, false, false, - ) + ctx.ast + .object_property_kind_object_property(SPAN, kind, key, value, false, false, false) }; let column_number = { @@ -175,9 +172,8 @@ impl<'a, 'ctx> JsxSource<'a, 'ctx> { column.to_string(), NumberBase::Decimal, ); - ctx.ast.object_property_kind_object_property( - SPAN, kind, key, value, None, false, false, false, - ) + ctx.ast + .object_property_kind_object_property(SPAN, kind, key, value, false, false, false) }; let mut properties = ctx.ast.vec_with_capacity(3); diff --git a/crates/oxc_traverse/src/generated/ancestor.rs b/crates/oxc_traverse/src/generated/ancestor.rs index deea73603883a..0f86473372499 100644 --- a/crates/oxc_traverse/src/generated/ancestor.rs +++ b/crates/oxc_traverse/src/generated/ancestor.rs @@ -32,293 +32,292 @@ pub(crate) enum AncestorType { ObjectExpressionProperties = 5, ObjectPropertyKey = 6, ObjectPropertyValue = 7, - ObjectPropertyInit = 8, - TemplateLiteralQuasis = 9, - TemplateLiteralExpressions = 10, - TaggedTemplateExpressionTag = 11, - TaggedTemplateExpressionQuasi = 12, - TaggedTemplateExpressionTypeParameters = 13, - ComputedMemberExpressionObject = 14, - ComputedMemberExpressionExpression = 15, - StaticMemberExpressionObject = 16, - StaticMemberExpressionProperty = 17, - PrivateFieldExpressionObject = 18, - PrivateFieldExpressionField = 19, - CallExpressionCallee = 20, - CallExpressionTypeParameters = 21, - CallExpressionArguments = 22, - NewExpressionCallee = 23, - NewExpressionArguments = 24, - NewExpressionTypeParameters = 25, - MetaPropertyMeta = 26, - MetaPropertyProperty = 27, - SpreadElementArgument = 28, - UpdateExpressionArgument = 29, - UnaryExpressionArgument = 30, - BinaryExpressionLeft = 31, - BinaryExpressionRight = 32, - PrivateInExpressionLeft = 33, - PrivateInExpressionRight = 34, - LogicalExpressionLeft = 35, - LogicalExpressionRight = 36, - ConditionalExpressionTest = 37, - ConditionalExpressionConsequent = 38, - ConditionalExpressionAlternate = 39, - AssignmentExpressionLeft = 40, - AssignmentExpressionRight = 41, - ArrayAssignmentTargetElements = 42, - ArrayAssignmentTargetRest = 43, - ObjectAssignmentTargetProperties = 44, - ObjectAssignmentTargetRest = 45, - AssignmentTargetRestTarget = 46, - AssignmentTargetWithDefaultBinding = 47, - AssignmentTargetWithDefaultInit = 48, - AssignmentTargetPropertyIdentifierBinding = 49, - AssignmentTargetPropertyIdentifierInit = 50, - AssignmentTargetPropertyPropertyName = 51, - AssignmentTargetPropertyPropertyBinding = 52, - SequenceExpressionExpressions = 53, - AwaitExpressionArgument = 54, - ChainExpressionExpression = 55, - ParenthesizedExpressionExpression = 56, - DirectiveExpression = 57, - BlockStatementBody = 58, - VariableDeclarationDeclarations = 59, - VariableDeclaratorId = 60, - VariableDeclaratorInit = 61, - ExpressionStatementExpression = 62, - IfStatementTest = 63, - IfStatementConsequent = 64, - IfStatementAlternate = 65, - DoWhileStatementBody = 66, - DoWhileStatementTest = 67, - WhileStatementTest = 68, - WhileStatementBody = 69, - ForStatementInit = 70, - ForStatementTest = 71, - ForStatementUpdate = 72, - ForStatementBody = 73, - ForInStatementLeft = 74, - ForInStatementRight = 75, - ForInStatementBody = 76, - ForOfStatementLeft = 77, - ForOfStatementRight = 78, - ForOfStatementBody = 79, - ContinueStatementLabel = 80, - BreakStatementLabel = 81, - ReturnStatementArgument = 82, - WithStatementObject = 83, - WithStatementBody = 84, - SwitchStatementDiscriminant = 85, - SwitchStatementCases = 86, - SwitchCaseTest = 87, - SwitchCaseConsequent = 88, - LabeledStatementLabel = 89, - LabeledStatementBody = 90, - ThrowStatementArgument = 91, - TryStatementBlock = 92, - TryStatementHandler = 93, - TryStatementFinalizer = 94, - CatchClauseParam = 95, - CatchClauseBody = 96, - CatchParameterPattern = 97, - BindingPatternKind = 98, - BindingPatternTypeAnnotation = 99, - AssignmentPatternLeft = 100, - AssignmentPatternRight = 101, - ObjectPatternProperties = 102, - ObjectPatternRest = 103, - BindingPropertyKey = 104, - BindingPropertyValue = 105, - ArrayPatternElements = 106, - ArrayPatternRest = 107, - BindingRestElementArgument = 108, - FunctionId = 109, - FunctionTypeParameters = 110, - FunctionThisParam = 111, - FunctionParams = 112, - FunctionReturnType = 113, - FunctionBody = 114, - FormalParametersItems = 115, - FormalParametersRest = 116, - FormalParameterDecorators = 117, - FormalParameterPattern = 118, - FunctionBodyDirectives = 119, - FunctionBodyStatements = 120, - ArrowFunctionExpressionTypeParameters = 121, - ArrowFunctionExpressionParams = 122, - ArrowFunctionExpressionReturnType = 123, - ArrowFunctionExpressionBody = 124, - YieldExpressionArgument = 125, - ClassDecorators = 126, - ClassId = 127, - ClassTypeParameters = 128, - ClassSuperClass = 129, - ClassSuperTypeParameters = 130, - ClassImplements = 131, - ClassBody = 132, - ClassBodyBody = 133, - MethodDefinitionDecorators = 134, - MethodDefinitionKey = 135, - MethodDefinitionValue = 136, - PropertyDefinitionDecorators = 137, - PropertyDefinitionKey = 138, - PropertyDefinitionValue = 139, - PropertyDefinitionTypeAnnotation = 140, - StaticBlockBody = 141, - AccessorPropertyDecorators = 142, - AccessorPropertyKey = 143, - AccessorPropertyValue = 144, - AccessorPropertyTypeAnnotation = 145, - ImportExpressionSource = 146, - ImportExpressionArguments = 147, - ImportDeclarationSpecifiers = 148, - ImportDeclarationSource = 149, - ImportDeclarationWithClause = 150, - ImportSpecifierImported = 151, - ImportSpecifierLocal = 152, - ImportDefaultSpecifierLocal = 153, - ImportNamespaceSpecifierLocal = 154, - WithClauseAttributesKeyword = 155, - WithClauseWithEntries = 156, - ImportAttributeKey = 157, - ImportAttributeValue = 158, - ExportNamedDeclarationDeclaration = 159, - ExportNamedDeclarationSpecifiers = 160, - ExportNamedDeclarationSource = 161, - ExportNamedDeclarationWithClause = 162, - ExportDefaultDeclarationDeclaration = 163, - ExportDefaultDeclarationExported = 164, - ExportAllDeclarationExported = 165, - ExportAllDeclarationSource = 166, - ExportAllDeclarationWithClause = 167, - ExportSpecifierLocal = 168, - ExportSpecifierExported = 169, - JSXElementOpeningElement = 170, - JSXElementClosingElement = 171, - JSXElementChildren = 172, - JSXOpeningElementName = 173, - JSXOpeningElementAttributes = 174, - JSXOpeningElementTypeParameters = 175, - JSXClosingElementName = 176, - JSXFragmentChildren = 177, - JSXNamespacedNameNamespace = 178, - JSXNamespacedNameProperty = 179, - JSXMemberExpressionObject = 180, - JSXMemberExpressionProperty = 181, - JSXExpressionContainerExpression = 182, - JSXAttributeName = 183, - JSXAttributeValue = 184, - JSXSpreadAttributeArgument = 185, - JSXSpreadChildExpression = 186, - TSThisParameterTypeAnnotation = 187, - TSEnumDeclarationId = 188, - TSEnumDeclarationMembers = 189, - TSEnumMemberId = 190, - TSEnumMemberInitializer = 191, - TSTypeAnnotationTypeAnnotation = 192, - TSLiteralTypeLiteral = 193, - TSConditionalTypeCheckType = 194, - TSConditionalTypeExtendsType = 195, - TSConditionalTypeTrueType = 196, - TSConditionalTypeFalseType = 197, - TSUnionTypeTypes = 198, - TSIntersectionTypeTypes = 199, - TSParenthesizedTypeTypeAnnotation = 200, - TSTypeOperatorTypeAnnotation = 201, - TSArrayTypeElementType = 202, - TSIndexedAccessTypeObjectType = 203, - TSIndexedAccessTypeIndexType = 204, - TSTupleTypeElementTypes = 205, - TSNamedTupleMemberElementType = 206, - TSNamedTupleMemberLabel = 207, - TSOptionalTypeTypeAnnotation = 208, - TSRestTypeTypeAnnotation = 209, - TSTypeReferenceTypeName = 210, - TSTypeReferenceTypeParameters = 211, - TSQualifiedNameLeft = 212, - TSQualifiedNameRight = 213, - TSTypeParameterInstantiationParams = 214, - TSTypeParameterName = 215, - TSTypeParameterConstraint = 216, - TSTypeParameterDefault = 217, - TSTypeParameterDeclarationParams = 218, - TSTypeAliasDeclarationId = 219, - TSTypeAliasDeclarationTypeParameters = 220, - TSTypeAliasDeclarationTypeAnnotation = 221, - TSClassImplementsExpression = 222, - TSClassImplementsTypeParameters = 223, - TSInterfaceDeclarationId = 224, - TSInterfaceDeclarationExtends = 225, - TSInterfaceDeclarationTypeParameters = 226, - TSInterfaceDeclarationBody = 227, - TSInterfaceBodyBody = 228, - TSPropertySignatureKey = 229, - TSPropertySignatureTypeAnnotation = 230, - TSIndexSignatureParameters = 231, - TSIndexSignatureTypeAnnotation = 232, - TSCallSignatureDeclarationTypeParameters = 233, - TSCallSignatureDeclarationThisParam = 234, - TSCallSignatureDeclarationParams = 235, - TSCallSignatureDeclarationReturnType = 236, - TSMethodSignatureKey = 237, - TSMethodSignatureTypeParameters = 238, - TSMethodSignatureThisParam = 239, - TSMethodSignatureParams = 240, - TSMethodSignatureReturnType = 241, - TSConstructSignatureDeclarationTypeParameters = 242, - TSConstructSignatureDeclarationParams = 243, - TSConstructSignatureDeclarationReturnType = 244, - TSIndexSignatureNameTypeAnnotation = 245, - TSInterfaceHeritageExpression = 246, - TSInterfaceHeritageTypeParameters = 247, - TSTypePredicateParameterName = 248, - TSTypePredicateTypeAnnotation = 249, - TSModuleDeclarationId = 250, - TSModuleDeclarationBody = 251, - TSModuleBlockDirectives = 252, - TSModuleBlockBody = 253, - TSTypeLiteralMembers = 254, - TSInferTypeTypeParameter = 255, - TSTypeQueryExprName = 256, - TSTypeQueryTypeParameters = 257, - TSImportTypeParameter = 258, - TSImportTypeQualifier = 259, - TSImportTypeAttributes = 260, - TSImportTypeTypeParameters = 261, - TSImportAttributesAttributesKeyword = 262, - TSImportAttributesElements = 263, - TSImportAttributeName = 264, - TSImportAttributeValue = 265, - TSFunctionTypeTypeParameters = 266, - TSFunctionTypeThisParam = 267, - TSFunctionTypeParams = 268, - TSFunctionTypeReturnType = 269, - TSConstructorTypeTypeParameters = 270, - TSConstructorTypeParams = 271, - TSConstructorTypeReturnType = 272, - TSMappedTypeTypeParameter = 273, - TSMappedTypeNameType = 274, - TSMappedTypeTypeAnnotation = 275, - TSTemplateLiteralTypeQuasis = 276, - TSTemplateLiteralTypeTypes = 277, - TSAsExpressionExpression = 278, - TSAsExpressionTypeAnnotation = 279, - TSSatisfiesExpressionExpression = 280, - TSSatisfiesExpressionTypeAnnotation = 281, - TSTypeAssertionExpression = 282, - TSTypeAssertionTypeAnnotation = 283, - TSImportEqualsDeclarationId = 284, - TSImportEqualsDeclarationModuleReference = 285, - TSExternalModuleReferenceExpression = 286, - TSNonNullExpressionExpression = 287, - DecoratorExpression = 288, - TSExportAssignmentExpression = 289, - TSNamespaceExportDeclarationId = 290, - TSInstantiationExpressionExpression = 291, - TSInstantiationExpressionTypeParameters = 292, - JSDocNullableTypeTypeAnnotation = 293, - JSDocNonNullableTypeTypeAnnotation = 294, + TemplateLiteralQuasis = 8, + TemplateLiteralExpressions = 9, + TaggedTemplateExpressionTag = 10, + TaggedTemplateExpressionQuasi = 11, + TaggedTemplateExpressionTypeParameters = 12, + ComputedMemberExpressionObject = 13, + ComputedMemberExpressionExpression = 14, + StaticMemberExpressionObject = 15, + StaticMemberExpressionProperty = 16, + PrivateFieldExpressionObject = 17, + PrivateFieldExpressionField = 18, + CallExpressionCallee = 19, + CallExpressionTypeParameters = 20, + CallExpressionArguments = 21, + NewExpressionCallee = 22, + NewExpressionArguments = 23, + NewExpressionTypeParameters = 24, + MetaPropertyMeta = 25, + MetaPropertyProperty = 26, + SpreadElementArgument = 27, + UpdateExpressionArgument = 28, + UnaryExpressionArgument = 29, + BinaryExpressionLeft = 30, + BinaryExpressionRight = 31, + PrivateInExpressionLeft = 32, + PrivateInExpressionRight = 33, + LogicalExpressionLeft = 34, + LogicalExpressionRight = 35, + ConditionalExpressionTest = 36, + ConditionalExpressionConsequent = 37, + ConditionalExpressionAlternate = 38, + AssignmentExpressionLeft = 39, + AssignmentExpressionRight = 40, + ArrayAssignmentTargetElements = 41, + ArrayAssignmentTargetRest = 42, + ObjectAssignmentTargetProperties = 43, + ObjectAssignmentTargetRest = 44, + AssignmentTargetRestTarget = 45, + AssignmentTargetWithDefaultBinding = 46, + AssignmentTargetWithDefaultInit = 47, + AssignmentTargetPropertyIdentifierBinding = 48, + AssignmentTargetPropertyIdentifierInit = 49, + AssignmentTargetPropertyPropertyName = 50, + AssignmentTargetPropertyPropertyBinding = 51, + SequenceExpressionExpressions = 52, + AwaitExpressionArgument = 53, + ChainExpressionExpression = 54, + ParenthesizedExpressionExpression = 55, + DirectiveExpression = 56, + BlockStatementBody = 57, + VariableDeclarationDeclarations = 58, + VariableDeclaratorId = 59, + VariableDeclaratorInit = 60, + ExpressionStatementExpression = 61, + IfStatementTest = 62, + IfStatementConsequent = 63, + IfStatementAlternate = 64, + DoWhileStatementBody = 65, + DoWhileStatementTest = 66, + WhileStatementTest = 67, + WhileStatementBody = 68, + ForStatementInit = 69, + ForStatementTest = 70, + ForStatementUpdate = 71, + ForStatementBody = 72, + ForInStatementLeft = 73, + ForInStatementRight = 74, + ForInStatementBody = 75, + ForOfStatementLeft = 76, + ForOfStatementRight = 77, + ForOfStatementBody = 78, + ContinueStatementLabel = 79, + BreakStatementLabel = 80, + ReturnStatementArgument = 81, + WithStatementObject = 82, + WithStatementBody = 83, + SwitchStatementDiscriminant = 84, + SwitchStatementCases = 85, + SwitchCaseTest = 86, + SwitchCaseConsequent = 87, + LabeledStatementLabel = 88, + LabeledStatementBody = 89, + ThrowStatementArgument = 90, + TryStatementBlock = 91, + TryStatementHandler = 92, + TryStatementFinalizer = 93, + CatchClauseParam = 94, + CatchClauseBody = 95, + CatchParameterPattern = 96, + BindingPatternKind = 97, + BindingPatternTypeAnnotation = 98, + AssignmentPatternLeft = 99, + AssignmentPatternRight = 100, + ObjectPatternProperties = 101, + ObjectPatternRest = 102, + BindingPropertyKey = 103, + BindingPropertyValue = 104, + ArrayPatternElements = 105, + ArrayPatternRest = 106, + BindingRestElementArgument = 107, + FunctionId = 108, + FunctionTypeParameters = 109, + FunctionThisParam = 110, + FunctionParams = 111, + FunctionReturnType = 112, + FunctionBody = 113, + FormalParametersItems = 114, + FormalParametersRest = 115, + FormalParameterDecorators = 116, + FormalParameterPattern = 117, + FunctionBodyDirectives = 118, + FunctionBodyStatements = 119, + ArrowFunctionExpressionTypeParameters = 120, + ArrowFunctionExpressionParams = 121, + ArrowFunctionExpressionReturnType = 122, + ArrowFunctionExpressionBody = 123, + YieldExpressionArgument = 124, + ClassDecorators = 125, + ClassId = 126, + ClassTypeParameters = 127, + ClassSuperClass = 128, + ClassSuperTypeParameters = 129, + ClassImplements = 130, + ClassBody = 131, + ClassBodyBody = 132, + MethodDefinitionDecorators = 133, + MethodDefinitionKey = 134, + MethodDefinitionValue = 135, + PropertyDefinitionDecorators = 136, + PropertyDefinitionKey = 137, + PropertyDefinitionValue = 138, + PropertyDefinitionTypeAnnotation = 139, + StaticBlockBody = 140, + AccessorPropertyDecorators = 141, + AccessorPropertyKey = 142, + AccessorPropertyValue = 143, + AccessorPropertyTypeAnnotation = 144, + ImportExpressionSource = 145, + ImportExpressionArguments = 146, + ImportDeclarationSpecifiers = 147, + ImportDeclarationSource = 148, + ImportDeclarationWithClause = 149, + ImportSpecifierImported = 150, + ImportSpecifierLocal = 151, + ImportDefaultSpecifierLocal = 152, + ImportNamespaceSpecifierLocal = 153, + WithClauseAttributesKeyword = 154, + WithClauseWithEntries = 155, + ImportAttributeKey = 156, + ImportAttributeValue = 157, + ExportNamedDeclarationDeclaration = 158, + ExportNamedDeclarationSpecifiers = 159, + ExportNamedDeclarationSource = 160, + ExportNamedDeclarationWithClause = 161, + ExportDefaultDeclarationDeclaration = 162, + ExportDefaultDeclarationExported = 163, + ExportAllDeclarationExported = 164, + ExportAllDeclarationSource = 165, + ExportAllDeclarationWithClause = 166, + ExportSpecifierLocal = 167, + ExportSpecifierExported = 168, + JSXElementOpeningElement = 169, + JSXElementClosingElement = 170, + JSXElementChildren = 171, + JSXOpeningElementName = 172, + JSXOpeningElementAttributes = 173, + JSXOpeningElementTypeParameters = 174, + JSXClosingElementName = 175, + JSXFragmentChildren = 176, + JSXNamespacedNameNamespace = 177, + JSXNamespacedNameProperty = 178, + JSXMemberExpressionObject = 179, + JSXMemberExpressionProperty = 180, + JSXExpressionContainerExpression = 181, + JSXAttributeName = 182, + JSXAttributeValue = 183, + JSXSpreadAttributeArgument = 184, + JSXSpreadChildExpression = 185, + TSThisParameterTypeAnnotation = 186, + TSEnumDeclarationId = 187, + TSEnumDeclarationMembers = 188, + TSEnumMemberId = 189, + TSEnumMemberInitializer = 190, + TSTypeAnnotationTypeAnnotation = 191, + TSLiteralTypeLiteral = 192, + TSConditionalTypeCheckType = 193, + TSConditionalTypeExtendsType = 194, + TSConditionalTypeTrueType = 195, + TSConditionalTypeFalseType = 196, + TSUnionTypeTypes = 197, + TSIntersectionTypeTypes = 198, + TSParenthesizedTypeTypeAnnotation = 199, + TSTypeOperatorTypeAnnotation = 200, + TSArrayTypeElementType = 201, + TSIndexedAccessTypeObjectType = 202, + TSIndexedAccessTypeIndexType = 203, + TSTupleTypeElementTypes = 204, + TSNamedTupleMemberElementType = 205, + TSNamedTupleMemberLabel = 206, + TSOptionalTypeTypeAnnotation = 207, + TSRestTypeTypeAnnotation = 208, + TSTypeReferenceTypeName = 209, + TSTypeReferenceTypeParameters = 210, + TSQualifiedNameLeft = 211, + TSQualifiedNameRight = 212, + TSTypeParameterInstantiationParams = 213, + TSTypeParameterName = 214, + TSTypeParameterConstraint = 215, + TSTypeParameterDefault = 216, + TSTypeParameterDeclarationParams = 217, + TSTypeAliasDeclarationId = 218, + TSTypeAliasDeclarationTypeParameters = 219, + TSTypeAliasDeclarationTypeAnnotation = 220, + TSClassImplementsExpression = 221, + TSClassImplementsTypeParameters = 222, + TSInterfaceDeclarationId = 223, + TSInterfaceDeclarationExtends = 224, + TSInterfaceDeclarationTypeParameters = 225, + TSInterfaceDeclarationBody = 226, + TSInterfaceBodyBody = 227, + TSPropertySignatureKey = 228, + TSPropertySignatureTypeAnnotation = 229, + TSIndexSignatureParameters = 230, + TSIndexSignatureTypeAnnotation = 231, + TSCallSignatureDeclarationTypeParameters = 232, + TSCallSignatureDeclarationThisParam = 233, + TSCallSignatureDeclarationParams = 234, + TSCallSignatureDeclarationReturnType = 235, + TSMethodSignatureKey = 236, + TSMethodSignatureTypeParameters = 237, + TSMethodSignatureThisParam = 238, + TSMethodSignatureParams = 239, + TSMethodSignatureReturnType = 240, + TSConstructSignatureDeclarationTypeParameters = 241, + TSConstructSignatureDeclarationParams = 242, + TSConstructSignatureDeclarationReturnType = 243, + TSIndexSignatureNameTypeAnnotation = 244, + TSInterfaceHeritageExpression = 245, + TSInterfaceHeritageTypeParameters = 246, + TSTypePredicateParameterName = 247, + TSTypePredicateTypeAnnotation = 248, + TSModuleDeclarationId = 249, + TSModuleDeclarationBody = 250, + TSModuleBlockDirectives = 251, + TSModuleBlockBody = 252, + TSTypeLiteralMembers = 253, + TSInferTypeTypeParameter = 254, + TSTypeQueryExprName = 255, + TSTypeQueryTypeParameters = 256, + TSImportTypeParameter = 257, + TSImportTypeQualifier = 258, + TSImportTypeAttributes = 259, + TSImportTypeTypeParameters = 260, + TSImportAttributesAttributesKeyword = 261, + TSImportAttributesElements = 262, + TSImportAttributeName = 263, + TSImportAttributeValue = 264, + TSFunctionTypeTypeParameters = 265, + TSFunctionTypeThisParam = 266, + TSFunctionTypeParams = 267, + TSFunctionTypeReturnType = 268, + TSConstructorTypeTypeParameters = 269, + TSConstructorTypeParams = 270, + TSConstructorTypeReturnType = 271, + TSMappedTypeTypeParameter = 272, + TSMappedTypeNameType = 273, + TSMappedTypeTypeAnnotation = 274, + TSTemplateLiteralTypeQuasis = 275, + TSTemplateLiteralTypeTypes = 276, + TSAsExpressionExpression = 277, + TSAsExpressionTypeAnnotation = 278, + TSSatisfiesExpressionExpression = 279, + TSSatisfiesExpressionTypeAnnotation = 280, + TSTypeAssertionExpression = 281, + TSTypeAssertionTypeAnnotation = 282, + TSImportEqualsDeclarationId = 283, + TSImportEqualsDeclarationModuleReference = 284, + TSExternalModuleReferenceExpression = 285, + TSNonNullExpressionExpression = 286, + DecoratorExpression = 287, + TSExportAssignmentExpression = 288, + TSNamespaceExportDeclarationId = 289, + TSInstantiationExpressionExpression = 290, + TSInstantiationExpressionTypeParameters = 291, + JSDocNullableTypeTypeAnnotation = 292, + JSDocNonNullableTypeTypeAnnotation = 293, } /// Ancestor type used in AST traversal. @@ -353,7 +352,6 @@ pub enum Ancestor<'a, 't> { ObjectPropertyKey(ObjectPropertyWithoutKey<'a, 't>) = AncestorType::ObjectPropertyKey as u16, ObjectPropertyValue(ObjectPropertyWithoutValue<'a, 't>) = AncestorType::ObjectPropertyValue as u16, - ObjectPropertyInit(ObjectPropertyWithoutInit<'a, 't>) = AncestorType::ObjectPropertyInit as u16, TemplateLiteralQuasis(TemplateLiteralWithoutQuasis<'a, 't>) = AncestorType::TemplateLiteralQuasis as u16, TemplateLiteralExpressions(TemplateLiteralWithoutExpressions<'a, 't>) = @@ -910,10 +908,7 @@ impl<'a, 't> Ancestor<'a, 't> { #[inline] pub fn is_object_property(self) -> bool { - matches!( - self, - Self::ObjectPropertyKey(_) | Self::ObjectPropertyValue(_) | Self::ObjectPropertyInit(_) - ) + matches!(self, Self::ObjectPropertyKey(_) | Self::ObjectPropertyValue(_)) } #[inline] @@ -1915,7 +1910,6 @@ impl<'a, 't> Ancestor<'a, 't> { matches!( self, Self::ObjectPropertyValue(_) - | Self::ObjectPropertyInit(_) | Self::TemplateLiteralExpressions(_) | Self::TaggedTemplateExpressionTag(_) | Self::ComputedMemberExpressionObject(_) @@ -2212,7 +2206,6 @@ impl<'a, 't> GetAddress for Ancestor<'a, 't> { Self::ObjectExpressionProperties(a) => a.address(), Self::ObjectPropertyKey(a) => a.address(), Self::ObjectPropertyValue(a) => a.address(), - Self::ObjectPropertyInit(a) => a.address(), Self::TemplateLiteralQuasis(a) => a.address(), Self::TemplateLiteralExpressions(a) => a.address(), Self::TaggedTemplateExpressionTag(a) => a.address(), @@ -2758,7 +2751,6 @@ pub(crate) const OFFSET_OBJECT_PROPERTY_SPAN: usize = offset_of!(ObjectProperty, pub(crate) const OFFSET_OBJECT_PROPERTY_KIND: usize = offset_of!(ObjectProperty, kind); pub(crate) const OFFSET_OBJECT_PROPERTY_KEY: usize = offset_of!(ObjectProperty, key); pub(crate) const OFFSET_OBJECT_PROPERTY_VALUE: usize = offset_of!(ObjectProperty, value); -pub(crate) const OFFSET_OBJECT_PROPERTY_INIT: usize = offset_of!(ObjectProperty, init); pub(crate) const OFFSET_OBJECT_PROPERTY_METHOD: usize = offset_of!(ObjectProperty, method); pub(crate) const OFFSET_OBJECT_PROPERTY_SHORTHAND: usize = offset_of!(ObjectProperty, shorthand); pub(crate) const OFFSET_OBJECT_PROPERTY_COMPUTED: usize = offset_of!(ObjectProperty, computed); @@ -2788,14 +2780,6 @@ impl<'a, 't> ObjectPropertyWithoutKey<'a, 't> { } } - #[inline] - pub fn init(self) -> &'t Option> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_INIT) - as *const Option>) - } - } - #[inline] pub fn method(self) -> &'t bool { unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_METHOD) as *const bool) } @@ -2844,14 +2828,6 @@ impl<'a, 't> ObjectPropertyWithoutValue<'a, 't> { } } - #[inline] - pub fn init(self) -> &'t Option> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_INIT) - as *const Option>) - } - } - #[inline] pub fn method(self) -> &'t bool { unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_METHOD) as *const bool) } @@ -2875,61 +2851,6 @@ impl<'a, 't> GetAddress for ObjectPropertyWithoutValue<'a, 't> { } } -#[repr(transparent)] -#[derive(Clone, Copy, Debug)] -pub struct ObjectPropertyWithoutInit<'a, 't>( - pub(crate) *const ObjectProperty<'a>, - pub(crate) PhantomData<&'t ()>, -); - -impl<'a, 't> ObjectPropertyWithoutInit<'a, 't> { - #[inline] - pub fn span(self) -> &'t Span { - unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SPAN) as *const Span) } - } - - #[inline] - pub fn kind(self) -> &'t PropertyKind { - unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_KIND) as *const PropertyKind) } - } - - #[inline] - pub fn key(self) -> &'t PropertyKey<'a> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_KEY) as *const PropertyKey<'a>) - } - } - - #[inline] - pub fn value(self) -> &'t Expression<'a> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_VALUE) as *const Expression<'a>) - } - } - - #[inline] - pub fn method(self) -> &'t bool { - unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_METHOD) as *const bool) } - } - - #[inline] - pub fn shorthand(self) -> &'t bool { - unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SHORTHAND) as *const bool) } - } - - #[inline] - pub fn computed(self) -> &'t bool { - unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_COMPUTED) as *const bool) } - } -} - -impl<'a, 't> GetAddress for ObjectPropertyWithoutInit<'a, 't> { - #[inline] - fn address(&self) -> Address { - Address::from_ptr(self.0) - } -} - pub(crate) const OFFSET_TEMPLATE_LITERAL_SPAN: usize = offset_of!(TemplateLiteral, span); pub(crate) const OFFSET_TEMPLATE_LITERAL_QUASIS: usize = offset_of!(TemplateLiteral, quasis); pub(crate) const OFFSET_TEMPLATE_LITERAL_EXPRESSIONS: usize = diff --git a/crates/oxc_traverse/src/generated/walk.rs b/crates/oxc_traverse/src/generated/walk.rs index 4546b8b3a56f1..a5fd5988d2111 100644 --- a/crates/oxc_traverse/src/generated/walk.rs +++ b/crates/oxc_traverse/src/generated/walk.rs @@ -373,12 +373,6 @@ pub(crate) unsafe fn walk_object_property<'a, Tr: Traverse<'a>>( (node as *mut u8).add(ancestor::OFFSET_OBJECT_PROPERTY_VALUE) as *mut Expression, ctx, ); - if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_OBJECT_PROPERTY_INIT) - as *mut Option) - { - ctx.retag_stack(AncestorType::ObjectPropertyInit); - walk_expression(traverser, field as *mut _, ctx); - } ctx.pop_stack(pop_token); traverser.exit_object_property(&mut *node, ctx); } diff --git a/npm/oxc-types/types.d.ts b/npm/oxc-types/types.d.ts index 6f225ac7b53bb..855dfc9b00044 100644 --- a/npm/oxc-types/types.d.ts +++ b/npm/oxc-types/types.d.ts @@ -138,7 +138,6 @@ export interface ObjectProperty extends Span { kind: PropertyKind; key: PropertyKey; value: Expression; - init: Expression | null; method: boolean; shorthand: boolean; computed: boolean; diff --git a/tasks/coverage/snapshots/parser_babel.snap b/tasks/coverage/snapshots/parser_babel.snap index 6ff0572164b4b..ec9ba51a4b298 100644 --- a/tasks/coverage/snapshots/parser_babel.snap +++ b/tasks/coverage/snapshots/parser_babel.snap @@ -5287,6 +5287,20 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc ╰──── help: Try insert a semicolon here + × Invalid assignment in object literal + ╭─[babel/packages/babel-parser/test/fixtures/es2017/async-functions/multiple-await-in-async-arrow-params/input.js:1:25] + 1 │ async ({ x = [ await ], y = { await } }) => {} + · ───────────── + ╰──── + help: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. + + × Invalid assignment in object literal + ╭─[babel/packages/babel-parser/test/fixtures/es2017/async-functions/multiple-await-in-async-arrow-params/input.js:1:10] + 1 │ async ({ x = [ await ], y = { await } }) => {} + · ───────────── + ╰──── + help: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. + × Line terminator not permitted before arrow ╭─[babel/packages/babel-parser/test/fixtures/es2017/async-functions/newline-before-arrow/input.js:2:1] 1 │ async x diff --git a/tasks/coverage/snapshots/parser_test262.snap b/tasks/coverage/snapshots/parser_test262.snap index 9b11503665686..b56752b632650 100644 --- a/tasks/coverage/snapshots/parser_test262.snap +++ b/tasks/coverage/snapshots/parser_test262.snap @@ -31726,6 +31726,15 @@ Expect Syntax Error: tasks/coverage/test262/test/language/import/import-attribut 23 │ // ╰──── + × Invalid assignment in object literal + ╭─[test262/test/language/statements/for/S12.6.3_A8_T3.js:22:6] + 21 │ //CHECK#1 + 22 │ for({index=0; index+=1;} index++<=10; index*2;) { arr.add(""+index);}; + · ─────── + 23 │ // + ╰──── + help: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. + × Async functions can only be declared at the top level or inside a block ╭─[test262/test/language/statements/for/decl-async-fun.js:21:18] 20 │ diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index bc7cf1b339507..d62539a9dce34 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -18439,6 +18439,24 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 51 │ } ╰──── + × Invalid assignment in object literal + ╭─[typescript/tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts:48:5] + 47 │ var h1 = { + 48 │ x = 1, + · ───── + 49 │ y = 2, + ╰──── + help: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. + + × Invalid assignment in object literal + ╭─[typescript/tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts:49:5] + 48 │ x = 1, + 49 │ y = 2, + · ───── + 50 │ #z: 3 + ╰──── + help: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. + × Cannot assign to this expression ╭─[typescript/tests/cases/conformance/expressions/operators/incrementAndDecrement.ts:8:1] 7 │ // Assign to expression++