-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed as not planned
Closed as not planned
Copy link
Labels
Area-CompilersFeature - Warning WavesWarning WavesWarning WavesFeature RequestResolution-By DesignThe behavior reported in the issue matches the current designThe behavior reported in the issue matches the current design
Milestone
Description
For example, the following code fails:
public class C
{
private readonly object _lock = new object();
public IEnumerable<int> Iterator()
{
lock (_lock)
yield return 0;
}
}
var c = new C();
foreach (var i in c.Iterator())
await Task.Yield();
The compiler should generate an error (or at least a warning) informing the user that the currently-executing thread after yield-returning may not be the same thread that the lock was taken on. Considering that the compiler already prevents awaiting in the body of a lock statement (Error CS1996) for the same reason, I feel like this addition would follow suit.
arnoldpistorius
Metadata
Metadata
Assignees
Labels
Area-CompilersFeature - Warning WavesWarning WavesWarning WavesFeature RequestResolution-By DesignThe behavior reported in the issue matches the current designThe behavior reported in the issue matches the current design