Enumerators fails to set state to "after" in various scenarios observable with GetEnumerator()
#76089
Labels
Area-Compilers
Code Gen Quality
Room for improvement in the quality of the compiler's generated code
Milestone
[jcouv update:] From discussion with Stephen we need to prioritize this. The optimization is meant to only kick once, but the current implementation would allow it to happen again.
With the latest implementation, you can
Dispose()
and thenGetEnumerator()
again and it will not allocate a new instance. But we want it to.The spec states that we should set state of the enumerator object to after in various scenarios:
yield break
is encounteredDispose
causes an exception to be thrownIt is possible to observe whether the state was properly set to after by checking whether
GetEnumerator()
re-uses the current state machine instance or allocates a new one.In the scenarios above, enumerators don't properly set the state to after.
The impact is not observable to my knowledge as we're making a change to ensure that
Dispose()
does set the state to after in non-exceptional cases, and this is only affecting an optimization.The text was updated successfully, but these errors were encountered: