Skip to content

Add test case where static field initialized with an anonymous class throws#4935

Open
G-Lee1031 wants to merge 1 commit intotc39:mainfrom
G-Lee1031:class-static-field
Open

Add test case where static field initialized with an anonymous class throws#4935
G-Lee1031 wants to merge 1 commit intotc39:mainfrom
G-Lee1031:class-static-field

Conversation

@G-Lee1031
Copy link
Contributor

Hello.
This PR adds an abrupt completion returning case of EvaluateBody of Initializer : = AssignmentExpression step 3.a.

  • First
    When declaring a class with a static field which has an initializer, EvaluateBody of Initializer : = AssignmentExpression is performed.
  • Second
    In step 3.a, NamedEvaluation of |Initializer| is performed.
  • Third
    In NamedEvaluation of ClassExpression : class ClassTail step 1, ClassDefinitionEvaluation of |ClassTail| is performed.
  • Fourth
    In this particular PR, the static field is defined as static field = class extends '' {};, which results in IsConstructor(superclass) to be false. So, in ClassDefinitionEvaluation of ClassTail : ClassHeritage? { ClassBody? } step 8.g, TypeError is thrown

@G-Lee1031 G-Lee1031 requested a review from a team as a code owner February 19, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants