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

[Proposal]: yield inside of try / catch #8414

Open
1 of 4 tasks
jaredpar opened this issue Sep 6, 2024 · 0 comments
Open
1 of 4 tasks

[Proposal]: yield inside of try / catch #8414

jaredpar opened this issue Sep 6, 2024 · 0 comments
Assignees

Comments

@jaredpar
Copy link
Member

jaredpar commented Sep 6, 2024

yield inside of try / catch

  • Proposed
  • Prototype: Not Started
  • Implementation: Not Started
  • Specification: Not Started

Summary

This expands the use of yield so it is permitted:

  • Inside the try portion of a try / catch block
  • Inside the catch portion of a try / catch with some restrictions on the presence of finally

Motivation

This is a long standing pain point in iterators that customers bring up with some regularity. The restriction exists largely because of limitations in the native compiler state machine rewriting code at the point iterators were implemented. The Roslyn compiler is capable of performing this type of rewrite, mostly through the innovations around async method state machines. Given that we should remove this restriction to make iterators more flexible.

Detailed design

Full details are in the proposal document.

#8413

Design meetings

@jaredpar jaredpar self-assigned this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant