Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synthesized constructor in ClassDefinitionEvaluation is missing [[PrivateMethods]] and [[Fields]] #3204

Open
linusg opened this issue Oct 19, 2023 · 1 comment
Labels

Comments

@linusg
Copy link
Member

linusg commented Oct 19, 2023

These are only present in ECMAScript Function Objects, however in the absence of a constructor method the function object is created as a Built-in Function Object:

b. Let F be CreateBuiltinFunction(defaultConstructor, 0, className, « [[ConstructorKind]], [[SourceText]] », the current Realm Record, constructorParent).

This makes the subsequent assignments invalid:

  1. Set F.[[PrivateMethods]] to instancePrivateMethods.
  2. Set F.[[Fields]] to instanceFields.

It's probably sufficient to add these two to the additional internal slots list passed to CreateBuiltinFunction.


Additionally, InitializeInstanceElements is being invoked from within the synthesized constructor's abstract closure, passing the active function object:

vi. Perform ? InitializeInstanceElements(result, F).

The AO has its argument typed as "an ECMAScript function object" and performs the same field access, which is problematic for the same reasons.

@ljharb
Copy link
Member

ljharb commented Oct 19, 2023

Adding the slots makes sense to me, and the AO certainly should check for the presence of the X slot before accessing it, either with an early return or with a type assertion on the parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants