-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
yield inside of try / catch
- Specification Allow yield inside of try / catch and catch #8413
- Discussion Champion: Remove error "Cannot yield a value in the body of a try block with a catch clause" #8994
Summary
This expands the use of yield so it is permitted:
- Inside the
tryportion of atry / catchblock - Inside the
catchportion of atry / catchwith some restrictions on the presence offinally
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.
Design meetings
MatisseHack, ufcpp, NN---, quinmars, huoyaoyuan and 17 more