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

Fix return and throw propagation for yield* #24463

Merged
merged 1 commit into from May 29, 2018
Merged

Fix return and throw propagation for yield* #24463

merged 1 commit into from May 29, 2018

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented May 29, 2018

This fixes two issues in __generator:

  1. We do not correctly handle iter.return() when in a yield*, as per 14.4.13 step 7.c.viii.2.
  2. We do not correctly close the iterator delegated via yield* during iter.throw() when the delegated iterator does not have a throw method, as per 14.4.13 step 7.b.iii.4

This PR makes two changes to the __generator helper to fix these issues (respectively):

  1. We fix iter.return() on generators.ts:3256 by preserving the "return" opcode (2).
  2. We fix iter.throw() on generators.ts:3255 when y.throw is not present by calling (and ignoring the result of) y.return() if it exists.

Fixes #24288

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still wish we had functional tests for these helpers, tho.

@rbuckton
Copy link
Member Author

Sounds like something we should consider as part of the test262 tests?

@rbuckton rbuckton merged commit c1a5d9b into master May 29, 2018
@rbuckton rbuckton deleted the fix24288 branch May 29, 2018 20:34
@rbuckton
Copy link
Member Author

rbuckton commented Jun 7, 2018

@mhegazy do you want this ported to release-2.9 as well?

@mhegazy
Copy link
Contributor

mhegazy commented Jun 7, 2018

yes please.

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

Successfully merging this pull request may close these issues.

Generator with closure does not correctly handle return()
3 participants