-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Editorial: Initialize [[GeneratorState]] and [[AsyncGeneratorState]] #3383
Conversation
Confirmed the issue. An assertion is immediately violated in GeneratorStart and AsyncGeneratorStart. But instead of this fix, I think I would prefer to introduce a new enum value ( |
There's no need for a state prior to |
@bakkot Setting it to |
Thanks for the review! @michaelficarra You mean using the enum value @bakkot I think it would be more precise to fill out all fields before calling other AOs requiring Generator/AsyncGenerator as parameters. However, just dropping the assertion is also acceptable to me. After the editor's call, I will update this PR. |
@jhnaldo Unfortunately we didn't get to it this week. We'll try to get to it next week. |
I would prefer just dropping the assert as well.
GeneratorStart is, for all intents and purposes, the initialization code for newly created generators. Now, I think it's reasonable to say that it's perhaps too far away from the allocation site of generator objects. For that issue, I'd prefer to do something systematic instead of ad hoc for generators. For example, we can change OrdinaryObjectCreate to take a list of (internal slot, initial value) pairs instead of a list of internal slots. |
Yeah I think this is the case. Its initialisation should be "adjacent" to the object allocation. |
I think the assertion is technically correct, because 6.1.7.2 "Object Internal Methods and Internal Slots" says that "Unless specified otherwise, the initial value of an internal slot is the value undefined." However, I dislike that sentence, and would much rather see slots initialized to a reasonable value at creation time.
In my https://github.com/jmdyck/ecma262/tree/object_creation branch, I had OrdinaryObjectCreate (via MakeBasicObject) take a Record, where each field associated a slot's name with its initial value. (The branch is way out of date, but if you compare it to its parent, you'll get the idea.) (Mind you, it also introduces an ecmarkdown syntax for long record displays, one field per line, which isn't essential to substance of the changes, but kept me happy.) |
Oh, I missed that sentence. Thank you for correcting me. I totally agree with your opinion because initializing each internal slot with a proper value instead of |
@jhnaldo No please don't close the PR. I don't think any of us are happy with the type of every slot being implicitly unioned with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to initialise to ~suspended-start~
and clean up the implicit *undefined*
initialisation in a follow-up.
undefined
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
abae20c
to
cb2495c
Compare
In the GeneratorStart AO, the first step is the following assertion:
However, in the EvaluateGeneratorBody SDO for GeneratorBody, there is no initialization of the
[[GeneratorState]]
internal slot for the variable_G_
before passing it into the GeneratorStart AO:I think we need to initialize the
[[GeneratorState]]
with*undefined*
, similar to the following 5th step in the CreateIteratorFromClosure AO:I found a similar issue in the EvaluateAsyncGeneratorBody SDO for the AsyncGeneratorBody.