Editorial: Fix type mismatch for class without constructor #3664
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a class has no explicit constructor, ClassDefinitionEvaluation step 14.b creates the default constructor via CreateBuiltinFunction.
Later, step 14.a.vi calls InitializeInstanceElements(result, F), which expects its second parameter constructor to be an ECMAScript Function Object. However, actual F's type is a Built-in Function Object and this causes type mismatch.
For example:
This PR fixes the inconsistency in two parts
built-in function object
type to InitializeInstanceElements' second parameter(constructor
)In step 16, MakeConstructor already allows a Built-in Function Object type, so this brings the earlier step into line.
[[PrivateMethods]]
and[[Fields]]
to additionalInternalSlotList when calling CreateBuiltinFunction in step 14.bWithout these slots a built-in constructor produced for a class would not have the properties that InitializeInstanceElements step 1 and 3 and ClassDefinitionEvaluation steps 27 and 28 immediately access, causing an invalid operation (see Synthesized constructor in ClassDefinitionEvaluation is missing [[PrivateMethods]] and [[Fields]] #3204).
Fixes #3204.