-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Allow yield inside of try / catch and catch #8413
base: main
Are you sure you want to change the base?
Conversation
This proposal expands the use of `yield` to - `try` portion of a `try / catch` block - `catch` portion of a `try / catch` block with some restrictions around `finally`
Regarding |
I think the big problem is agreeing on what behavior Basically I think the problem is more along agreeing what behavior is correct vs. implementing that behavior. Can add this to open issues though in case there is broad agreement on what the best behavior is. |
|
||
### Code generation yield inside try / catch in async iterators | ||
|
||
The code generation for `try / catch` blocks in async iterators will be largely the same as traditional iterators. The difference is that the return type of generated `catch` methods will be `ValueTask` instead of `void`. |
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.
I didn't follow this. Async iterators are more like async state machines than iterator state machines.
Instead of generating a MoveNext and a Dispose method with similar structure, we use a single method (MoveNext) for both normal and disposal execution. A flag indicates if we're in disposal and we use it to skip over non-disposal code as appropriate.
So we shouldn't need to generate catch
methods.
Here are some notes on disposal in async iterators. Happy to discuss offline.
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.
Hmm. Maybe i was looking at the wrong code gen here. Will take a look at this.
Co-authored-by: Jan Jones <[email protected]>
This proposal expands the use of
yield
totry
portion of atry / catch
blockcatch
portion of atry / catch
block with some restrictions aroundfinally