fix(parser): fix enum member parsing (#4543)

Closes #4449
This commit is contained in:
DonIsaac 2024-07-30 10:43:09 +00:00
parent d384f6000a
commit d5c4b190aa
19 changed files with 292 additions and 23 deletions

View file

@ -115,8 +115,9 @@ inherit_variants! {
pub enum TSEnumMemberName<'a> {
StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64,
StaticStringLiteral(Box<'a, StringLiteral<'a>>) = 65,
StaticTemplateLiteral(Box<'a, TemplateLiteral<'a>>) = 66,
// Invalid Grammar `enum E { 1 }`
StaticNumericLiteral(Box<'a, NumericLiteral<'a>>) = 66,
StaticNumericLiteral(Box<'a, NumericLiteral<'a>>) = 67,
// Invalid Grammar `enum E { [computed] }`
// `Expression` variants added here by `inherit_variants!` macro
@inherit Expression

View file

@ -8116,6 +8116,37 @@ impl<'a> AstBuilder<'a> {
TSEnumMemberName::StaticStringLiteral(inner.into_in(self.allocator))
}
/// Build a [`TSEnumMemberName::StaticTemplateLiteral`]
///
/// This node contains a [`TemplateLiteral`] that will be stored in the memory arena.
///
/// ## Parameters
/// - span: The [`Span`] covering this node
/// - quasis
/// - expressions
#[inline]
pub fn ts_enum_member_name_template_literal(
self,
span: Span,
quasis: Vec<'a, TemplateElement<'a>>,
expressions: Vec<'a, Expression<'a>>,
) -> TSEnumMemberName<'a> {
TSEnumMemberName::StaticTemplateLiteral(self.alloc(self.template_literal(
span,
quasis,
expressions,
)))
}
/// Convert a [`TemplateLiteral`] into a [`TSEnumMemberName::StaticTemplateLiteral`]
#[inline]
pub fn ts_enum_member_name_from_template_literal<T>(self, inner: T) -> TSEnumMemberName<'a>
where
T: IntoIn<'a, Box<'a, TemplateLiteral<'a>>>,
{
TSEnumMemberName::StaticTemplateLiteral(inner.into_in(self.allocator))
}
/// Build a [`TSEnumMemberName::StaticNumericLiteral`]
///
/// This node contains a [`NumericLiteral`] that will be stored in the memory arena.

View file

@ -1278,6 +1278,7 @@ impl<'a> GetSpan for TSEnumMemberName<'a> {
match self {
Self::StaticIdentifier(it) => it.span(),
Self::StaticStringLiteral(it) => it.span(),
Self::StaticTemplateLiteral(it) => it.span(),
Self::StaticNumericLiteral(it) => it.span(),
Self::BooleanLiteral(it) => it.span(),
Self::NullLiteral(it) => it.span(),

View file

@ -3878,6 +3878,7 @@ pub mod walk {
match it {
TSEnumMemberName::StaticIdentifier(it) => visitor.visit_identifier_name(it),
TSEnumMemberName::StaticStringLiteral(it) => visitor.visit_string_literal(it),
TSEnumMemberName::StaticTemplateLiteral(it) => visitor.visit_template_literal(it),
TSEnumMemberName::StaticNumericLiteral(it) => visitor.visit_numeric_literal(it),
match_expression!(TSEnumMemberName) => visitor.visit_expression(it.to_expression()),
}

View file

@ -4102,6 +4102,7 @@ pub mod walk_mut {
match it {
TSEnumMemberName::StaticIdentifier(it) => visitor.visit_identifier_name(it),
TSEnumMemberName::StaticStringLiteral(it) => visitor.visit_string_literal(it),
TSEnumMemberName::StaticTemplateLiteral(it) => visitor.visit_template_literal(it),
TSEnumMemberName::StaticNumericLiteral(it) => visitor.visit_numeric_literal(it),
match_expression!(TSEnumMemberName) => visitor.visit_expression(it.to_expression_mut()),
}

View file

@ -3531,6 +3531,7 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSEnumMember<'a> {
match &self.id {
TSEnumMemberName::StaticIdentifier(decl) => decl.gen(p, ctx),
TSEnumMemberName::StaticStringLiteral(decl) => decl.gen(p, ctx),
TSEnumMemberName::StaticTemplateLiteral(decl) => decl.gen(p, ctx),
TSEnumMemberName::StaticNumericLiteral(decl) => decl.gen(p, ctx),
decl @ match_expression!(TSEnumMemberName) => {
p.print_str("[");

View file

@ -16,6 +16,8 @@ enum ConstantValue {
}
impl<'a> IsolatedDeclarations<'a> {
/// # Panics
/// if the enum member is a template literal with substitutions.
pub fn transform_ts_enum_declaration(
&mut self,
decl: &TSEnumDeclaration<'a>,
@ -45,6 +47,9 @@ impl<'a> IsolatedDeclarations<'a> {
let member_name = match &member.id {
TSEnumMemberName::StaticIdentifier(id) => &id.name,
TSEnumMemberName::StaticStringLiteral(str) => &str.value,
TSEnumMemberName::StaticTemplateLiteral(template) => {
&template.quasi().expect("Template enum members cannot have substitutions.")
}
#[allow(clippy::unnested_or_patterns)] // Clippy is wrong
TSEnumMemberName::StaticNumericLiteral(_)
| match_expression!(TSEnumMemberName) => {

View file

@ -449,3 +449,16 @@ pub fn accessibility_modifier_on_private_property(modifier: &Modifier) -> OxcDia
ts_error("18010", "An accessibility modifier cannot be used with a private identifier.")
.with_label(modifier.span)
}
// ================================== TS ENUMS =================================
/// Computed property names are not allowed in enums.ts(1164)
#[cold]
pub fn computed_property_names_not_allowed_in_enums(span: Span) -> OxcDiagnostic {
ts_error("1164", "Computed property names are not allowed in enums.").with_label(span)
}
/// An enum member cannot have a numeric name.ts(2452)
#[cold]
pub fn enum_member_cannot_have_numeric_name(span: Span) -> OxcDiagnostic {
ts_error("2452", "An enum member cannot have a numeric name.").with_label(span)
}

View file

@ -407,7 +407,7 @@ impl<'a> ParserImpl<'a> {
/// `TemplateLiteral`[Yield, Await, Tagged] :
/// `NoSubstitutionTemplate`
/// `SubstitutionTemplate`[?Yield, ?Await, ?Tagged]
fn parse_template_literal(&mut self, tagged: bool) -> Result<TemplateLiteral<'a>> {
pub(crate) fn parse_template_literal(&mut self, tagged: bool) -> Result<TemplateLiteral<'a>> {
let span = self.start_span();
let mut expressions = self.ast.vec();
let mut quasis = self.ast.vec();

View file

@ -1,7 +1,7 @@
use oxc_allocator::Box;
use oxc_ast::ast::*;
use oxc_diagnostics::Result;
use oxc_span::Span;
use oxc_span::{GetSpan, Span};
use crate::{
diagnostics,
@ -59,21 +59,37 @@ impl<'a> ParserImpl<'a> {
None
};
Ok(TSEnumMember { span: self.end_span(span), id, initializer })
let span = self.end_span(span);
if initializer.is_some() && matches!(id, TSEnumMemberName::StaticTemplateLiteral(_)) {
self.error(diagnostics::invalid_assignment(span));
}
Ok(TSEnumMember { span, id, initializer })
}
fn parse_ts_enum_member_name(&mut self) -> Result<TSEnumMemberName<'a>> {
match self.cur_kind() {
Kind::LBrack => {
let node = self.parse_computed_property_name()?;
self.check_invalid_ts_enum_computed_property(&node);
Ok(self.ast.ts_enum_member_name_expression(node))
}
Kind::Str => {
let node = self.parse_literal_string()?;
Ok(self.ast.ts_enum_member_name_from_string_literal(node))
}
Kind::NoSubstitutionTemplate | Kind::TemplateHead => {
let node = self.parse_template_literal(false)?;
if !node.expressions.is_empty() {
self.error(diagnostics::computed_property_names_not_allowed_in_enums(
node.span(),
));
}
Ok(self.ast.ts_enum_member_name_from_template_literal(node))
}
kind if kind.is_number() => {
let node = self.parse_literal_number()?;
self.error(diagnostics::enum_member_cannot_have_numeric_name(node.span()));
Ok(self.ast.ts_enum_member_name_from_numeric_literal(node))
}
_ => {
@ -82,6 +98,17 @@ impl<'a> ParserImpl<'a> {
}
}
}
fn check_invalid_ts_enum_computed_property(&mut self, property: &Expression<'a>) {
match property {
Expression::StringLiteral(_) => {}
Expression::TemplateLiteral(template) if template.expressions.is_empty() => {}
Expression::NumericLiteral(_) => {
self.error(diagnostics::enum_member_cannot_have_numeric_name(property.span()));
}
_ => self
.error(diagnostics::computed_property_names_not_allowed_in_enums(property.span())),
}
}
/** ------------------- Annotation ----------------- */

View file

@ -365,6 +365,9 @@ impl<'a> Binder<'a> for TSEnumMember<'a> {
let name = match &self.id {
TSEnumMemberName::StaticIdentifier(id) => Cow::Borrowed(id.name.as_str()),
TSEnumMemberName::StaticStringLiteral(s) => Cow::Borrowed(s.value.as_str()),
TSEnumMemberName::StaticTemplateLiteral(s) => Cow::Borrowed(
s.quasi().expect("Template enum members must have no substitutions.").as_str(),
),
TSEnumMemberName::StaticNumericLiteral(n) => Cow::Owned(n.value.to_string()),
match_expression!(TSEnumMemberName) => panic!("TODO: implement"),
};

View file

@ -203,11 +203,17 @@ impl<'a> TypeScriptEnum<'a> {
let mut prev_member_name: Option<Atom<'a>> = None;
for member in members {
let member_name = match &member.id {
let member_name: &Atom<'_> = match &member.id {
TSEnumMemberName::StaticIdentifier(id) => &id.name,
TSEnumMemberName::StaticStringLiteral(str) => &str.value,
#[allow(clippy::unnested_or_patterns)] // Clippy is wrong
TSEnumMemberName::StaticNumericLiteral(_) | match_expression!(TSEnumMemberName) => {
TSEnumMemberName::StaticStringLiteral(str)
| TSEnumMemberName::StringLiteral(str) => &str.value,
TSEnumMemberName::StaticTemplateLiteral(template)
| TSEnumMemberName::TemplateLiteral(template) => {
&template.quasi().expect("Template enum members cannot have substitutions.")
}
// parse error, but better than a panic
TSEnumMemberName::StaticNumericLiteral(n) => &Atom::from(n.raw),
match_expression!(TSEnumMemberName) => {
unreachable!()
}
};

View file

@ -3695,6 +3695,9 @@ pub(crate) unsafe fn walk_ts_enum_member_name<'a, Tr: Traverse<'a>>(
TSEnumMemberName::StaticStringLiteral(node) => {
walk_string_literal(traverser, (&mut **node) as *mut _, ctx)
}
TSEnumMemberName::StaticTemplateLiteral(node) => {
walk_template_literal(traverser, (&mut **node) as *mut _, ctx)
}
TSEnumMemberName::StaticNumericLiteral(node) => {
walk_numeric_literal(traverser, (&mut **node) as *mut _, ctx)
}

View file

@ -1,3 +1,3 @@
codegen_misc Summary:
AST Parsed : 24/24 (100.00%)
Positive Passed: 24/24 (100.00%)
AST Parsed : 25/25 (100.00%)
Positive Passed: 25/25 (100.00%)

View file

@ -0,0 +1,7 @@
// should fail
enum A { [foo] } // Computed property names are not allowed in enums
enum B { [1] } // An enum member cannot have a numeric name.
enum C { 1 } // An enum member cannot have a numeric name.
enum D { [`test${foo}`] } // Computed property names are not allowed in enums.
enum E { `baz` = 2 } // Enum member expected.
enum F { ['baz' + 'baz'] } // Computed property names are not allowed in enums.

View file

@ -0,0 +1,9 @@
// should work
enum A { ['baz'] } // ❌ currently fails
enum B { [`baz`] } // ❌ currently fails
enum C { ['baz'] = 2 } // ❌ currently fails
enum D { [`baz`] = 2 } // ❌ currently fails
enum E { 'baz' } // 👍 work fine
enum F { baz } // 👍 work fine
enum G { 'baz' = 2 } // 👍 work fine
enum H { baz = 2 } // 👍 work fine

View file

@ -1,7 +1,7 @@
parser_misc Summary:
AST Parsed : 24/24 (100.00%)
Positive Passed: 24/24 (100.00%)
Negative Passed: 13/13 (100.00%)
AST Parsed : 25/25 (100.00%)
Positive Passed: 25/25 (100.00%)
Negative Passed: 14/14 (100.00%)
× Unexpected token
╭─[fail/oxc-169.js:2:1]
@ -173,6 +173,53 @@ Negative Passed: 13/13 (100.00%)
╰────
help: Try insert a semicolon here
× TS(1164): Computed property names are not allowed in enums.
╭─[fail/oxc-4449.ts:2:11]
1 │ // should fail
2 │ enum A { [foo] } // Computed property names are not allowed in enums
· ───
3 │ enum B { [1] } // An enum member cannot have a numeric name.
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[fail/oxc-4449.ts:3:11]
2 │ enum A { [foo] } // Computed property names are not allowed in enums
3 │ enum B { [1] } // An enum member cannot have a numeric name.
· ─
4 │ enum C { 1 } // An enum member cannot have a numeric name.
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[fail/oxc-4449.ts:4:10]
3 │ enum B { [1] } // An enum member cannot have a numeric name.
4 │ enum C { 1 } // An enum member cannot have a numeric name.
· ─
5 │ enum D { [`test${foo}`] } // Computed property names are not allowed in enums.
╰────
× TS(1164): Computed property names are not allowed in enums.
╭─[fail/oxc-4449.ts:5:11]
4 │ enum C { 1 } // An enum member cannot have a numeric name.
5 │ enum D { [`test${foo}`] } // Computed property names are not allowed in enums.
· ────────────
6 │ enum E { `baz` = 2 } // Enum member expected.
╰────
× Cannot assign to this expression
╭─[fail/oxc-4449.ts:6:10]
5 │ enum D { [`test${foo}`] } // Computed property names are not allowed in enums.
6 │ enum E { `baz` = 2 } // Enum member expected.
· ─────────
7 │ enum F { ['baz' + 'baz'] } // Computed property names are not allowed in enums.
╰────
× TS(1164): Computed property names are not allowed in enums.
╭─[fail/oxc-4449.ts:7:11]
6 │ enum E { `baz` = 2 } // Enum member expected.
7 │ enum F { ['baz' + 'baz'] } // Computed property names are not allowed in enums.
· ─────────────
╰────
× The keyword 'let' is reserved
╭─[fail/oxc.js:1:1]
1 │ let.a = 1;

View file

@ -3,7 +3,7 @@ commit: d8086f14
parser_typescript Summary:
AST Parsed : 6444/6456 (99.81%)
Positive Passed: 6421/6456 (99.46%)
Negative Passed: 1160/5653 (20.52%)
Negative Passed: 1167/5653 (20.64%)
Expect Syntax Error: "compiler/ClassDeclaration10.ts"
Expect Syntax Error: "compiler/ClassDeclaration11.ts"
Expect Syntax Error: "compiler/ClassDeclaration13.ts"
@ -668,7 +668,6 @@ Expect Syntax Error: "compiler/enumAssignmentCompat7.ts"
Expect Syntax Error: "compiler/enumBasics1.ts"
Expect Syntax Error: "compiler/enumBasics2.ts"
Expect Syntax Error: "compiler/enumBasics3.ts"
Expect Syntax Error: "compiler/enumIdentifierLiterals.ts"
Expect Syntax Error: "compiler/enumLiteralAssignableToEnumInsideUnion.ts"
Expect Syntax Error: "compiler/enumNoInitializerFollowsNonLiteralInitializer.ts"
Expect Syntax Error: "compiler/enumPropertyAccess.ts"
@ -1331,7 +1330,6 @@ Expect Syntax Error: "compiler/limitDeepInstantiations.ts"
Expect Syntax Error: "compiler/literalFreshnessPropagationOnNarrowing.ts"
Expect Syntax Error: "compiler/literalTypeNameAssertionNotTriggered.ts"
Expect Syntax Error: "compiler/literals-negative.ts"
Expect Syntax Error: "compiler/literalsInComputedProperties1.ts"
Expect Syntax Error: "compiler/logicalNotExpression1.ts"
Expect Syntax Error: "compiler/mappedTypeAsStringTemplate.ts"
Expect Syntax Error: "compiler/mappedTypeGenericWithKnownKeys.ts"
@ -3729,7 +3727,6 @@ Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parse
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts"
@ -3738,7 +3735,6 @@ Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/par
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration7.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration9.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/EnumDeclarations/parserEnumDeclaration2.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/EnumDeclarations/parserEnumDeclaration3.d.ts"
Expect Syntax Error: "conformance/parser/ecmascript5/ErrorRecovery/AccessibilityAfterStatic/parserAccessibilityAfterStatic1.ts"
@ -3943,7 +3939,6 @@ Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parse
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts"
@ -3954,13 +3949,11 @@ Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parse
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts"
Expect Syntax Error: "conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts"
@ -7385,6 +7378,38 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
· ╰── It can not be redeclared here
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[compiler/enumIdentifierLiterals.ts:2:5]
1 │ enum Nums {
2 │ 1.0,
· ───
3 │ 11e-1,
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[compiler/enumIdentifierLiterals.ts:3:5]
2 │ 1.0,
3 │ 11e-1,
· ─────
4 │ 0.12e1,
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[compiler/enumIdentifierLiterals.ts:4:5]
3 │ 11e-1,
4 │ 0.12e1,
· ──────
5 │ "13e-1",
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[compiler/enumIdentifierLiterals.ts:6:5]
5 │ "13e-1",
6 │ 0xF00D
· ──────
7 │ }
╰────
× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[compiler/enumMemberResolution.ts:5:4]
4 │ var x = IgnoreRulesSpecific. // error
@ -9014,6 +9039,22 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
10 │ a.length;
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[compiler/literalsInComputedProperties1.ts:39:5]
38 │ enum X {
39 │ 1 = 1,
· ─
40 │ [2] = 2,
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[compiler/literalsInComputedProperties1.ts:40:6]
39 │ 1 = 1,
40 │ [2] = 2,
· ─
41 │ "3" = 3,
╰────
× Invalid Character `!`
╭─[compiler/manyCompilerErrorsInTheTwoFiles.ts:1:13]
1 │ const a =!@#!@$
@ -18615,6 +18656,14 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
· ╰── `,` expected
╰────
× TS(1164): Computed property names are not allowed in enums.
╭─[conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName6.ts:2:4]
1 │ enum E {
2 │ [e] = 1
· ─
3 │ }
╰────
× Type parameter list cannot be empty.
╭─[conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts:2:14]
1 │ class C {
@ -18666,6 +18715,30 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
3 │ enum E1 { a, b: 1, c, d: 2 = 3 }
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts:2:3]
1 │ enum E {
2 │ 1, 2, 3
· ─
3 │ }
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts:2:6]
1 │ enum E {
2 │ 1, 2, 3
· ─
3 │ }
╰────
× TS(2452): An enum member cannot have a numeric name.
╭─[conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts:2:9]
1 │ enum E {
2 │ 1, 2, 3
· ─
3 │ }
╰────
× Unexpected token
╭─[conformance/parser/ecmascript5/EnumDeclarations/parserEnumDeclaration4.ts:1:6]
1 │ enum void {
@ -20648,6 +20721,22 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
· ─
╰────
× TS(1164): Computed property names are not allowed in enums.
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName16.ts:2:4]
1 │ enum E {
2 │ [e] = 1
· ─
3 │ }
╰────
× TS(1164): Computed property names are not allowed in enums.
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName26.ts:3:6]
2 │ // No ASI
3 │ [e] = 0
· ─
4 │ [e2] = 1
╰────
× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts:4:9]
3 │ [e]: number = 0
@ -20657,6 +20746,14 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
╰────
help: Try insert a semicolon here
× TS(1164): Computed property names are not allowed in enums.
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts:3:6]
2 │ // no ASI, comma expected
3 │ [e] = id++
· ─
4 │ [e2] = 1
╰────
× Expected `,` but found `[`
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts:4:5]
3 │ [e] = id++
@ -20675,6 +20772,22 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
╰────
help: Try insert a semicolon here
× TS(1164): Computed property names are not allowed in enums.
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts:3:6]
2 │ // no ASI, comma expected
3 │ [e] = id++,
· ─
4 │ [e2] = 1
╰────
× TS(1164): Computed property names are not allowed in enums.
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts:4:6]
3 │ [e] = id++,
4 │ [e2] = 1
· ──
5 │ }
╰────
× Expected `]` but found `,`
╭─[conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts:2:7]
1 │ var x = {

View file

@ -1,3 +1,3 @@
transformer_misc Summary:
AST Parsed : 24/24 (100.00%)
Positive Passed: 24/24 (100.00%)
AST Parsed : 25/25 (100.00%)
Positive Passed: 25/25 (100.00%)