Skip to content

Editorial: FunctionDeclarationInstantiation cannot return ReturnCompletion #3607

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bakkot
Copy link
Contributor

@bakkot bakkot commented May 15, 2025

This is because the only way to get a return completion in expression position is with a yield, and yield is statically forbidden in generator formal parameters.

I suspect esmeta will complain about this, because FunctionDeclarationInstantiation calls IteratorBindingInitialization to do the initialization, and that AO is also used for let [foo] = bar declarations, which can contain yield expressions and therefore can produce return completions. I didn't think it was worth adding an assert in FunctionDeclarationInstantiation which says that IteratorBindingInitialization cannot produce a return completion in this specific case, but I'm open to doing so if we can do it without making the algorithm too awkward.

This imprecision is exposed by #3606 failing esmeta's typechecks. It should pass if rebased on this (I think).

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.

1 participant