Skip to content

fix for-in enumeration containing yield in generator#51295

Merged
rbuckton merged 1 commit intomainfrom
fix49808
Oct 28, 2022
Merged

fix for-in enumeration containing yield in generator#51295
rbuckton merged 1 commit intomainfrom
fix49808

Conversation

@rbuckton
Copy link
Copy Markdown
Contributor

@rbuckton rbuckton commented Oct 24, 2022

This updates the emit for a for..in statement containing a yield when emitting a downlevel generator to more accurately align with EnumerateObjectProperties, which states (emphasis added):

The iterator's throw and return methods are null and are never invoked. The iterator's next method processes object properties to determine whether the property key should be returned as an iterator value. Returned property keys do not include keys that are Symbols. Properties of the target object may be deleted during enumeration. A property that is deleted before it is processed by the iterator's next method is ignored. If new properties are added to the target object during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration.

This is achieved by adding an extra if (!(key in obj)) continue test at the top of the transformed loop body so that we can skip over deleted properties. We don't make any changes to handle newly added properties since that is spec'd to be implementation defined behavior (per the "not guaranteed" statement in the above condition).

Fixes #49808

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generator function es5 polyfill unexpected behavior in ForInStatement and deleteStatement

3 participants