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

don't automatically initialise all internal slots to undefined #3399

Open
michaelficarra opened this issue Aug 22, 2024 · 3 comments
Open

don't automatically initialise all internal slots to undefined #3399

michaelficarra opened this issue Aug 22, 2024 · 3 comments

Comments

@michaelficarra
Copy link
Member

We need to clean up how we create objects and set initial values of their internal slots. It is a common pattern today to call OrdinaryCreateFromConstructor with a list of additional slot names and then in the immediately following steps, set the initial values of each of these additional fields. But technically according to 6.1.7.2 Object Internal Methods and Internal Slots, these slots are given the value undefined in the interim.

Unless specified otherwise, the initial value of an internal slot is the value undefined.

This means that the declared type of each of these internal slots is implicitly unioned with undefined. We should instead create these slots and give them their initial values atomically, then remove this provision.

See related #3383.

@michaelficarra michaelficarra added editor call to be discussed in the next editor call and removed editor call to be discussed in the next editor call labels Aug 22, 2024
@syg
Copy link
Contributor

syg commented Aug 28, 2024

Recap of editor call:

  • Let's change MakeBasicObject to take anonymous records of { [[SlotName]]: initialValue } "templates"
  • Do the exercise of changing the callers to use the new form, which hopefully naturally points out where currently the initialization is already too far away from the allocation

@michaelficarra
Copy link
Member Author

And of course remove the implicit initialisation affordance.

@bakkot
Copy link
Contributor

bakkot commented Aug 28, 2024

MakeBasicObject is used upstream, at least in WebIDL but plausibly also other specs, so this will take at least a little integration work.

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

No branches or pull requests

3 participants