Allow ref-like locals in iterators and async methods#72664
Allow ref-like locals in iterators and async methods#72664jjonescz merged 26 commits intodotnet:features/RefInAsyncfrom
Conversation
src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/IteratorAndAsyncCaptureWalker.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/RefLocalsAndReturnsTests.cs
Outdated
Show resolved
Hide resolved
I actually meant to make In reply to: 2035256041 Refers to: src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs:20437 in d6dbc5f. [](commit_id = d6dbc5f, deletion_comment = False) |
I actually meant to make In reply to: 2035260444 Refers to: src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs:21284 in d6dbc5f. [](commit_id = d6dbc5f, deletion_comment = False) |
|
Done with review pass (commit 18) |
src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/IteratorAndAsyncCaptureWalker.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/IteratorAndAsyncCaptureWalker.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/RefLocalsAndReturnsTests.cs
Show resolved
Hide resolved
|
Done with review pass (commit 21) |
|
Done with review pass (commit 22). The only remaining issue I am tracking is #72664 (comment). |
AlekseyTs
left a comment
There was a problem hiding this comment.
LGTM (commit 23), assuming CI is passing
|
@cston for another look, thanks |
| // { | ||
| Diagnostic(ErrorCode.ERR_ByRefTypeAndAwait, @"{ | ||
| await Async1(F1(), G(F2(), stackalloc int[] { 1, 2, 3 }, await F3())); | ||
| }").WithArguments("System.Span<int>").WithLocation(8, 5) |
There was a problem hiding this comment.
Minor: Should the error location be stackalloc int[] { 1, 2, 3 } rather than the containing block? #WontFix
There was a problem hiding this comment.
That does not look easily doable. The problematic local used across await is a synthesized local whose syntax is the await F3() expression and the node where the usage after await occurs has the whole block as syntax (that's what's used to report the diagnostic, it seems more useful than the former in most scenarios). In any case, we do not seem to have the location of the stackalloc expression at hand.
It looks like this test wasn't part of this PR, but ... Actually, let's not make any changes since this is an existing test. #Resolved Refers to: src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAwaitForeachTests.cs:2049 in b4cc4b5. [](commit_id = b4cc4b5, deletion_comment = False) |
|
|
||
| [ConditionalFact(typeof(CoreClrOnly))] | ||
| public void UserDefinedIndexer_Warning_01() | ||
| public void UserDefinedIndexer_Warning_17() |
Not sure if the scenario with ref struct Current is tested elsewhere, so I will add a new test for that. Thanks. In reply to: 2057185471 Refers to: src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAwaitForeachTests.cs:2049 in b4cc4b5. [](commit_id = b4cc4b5, deletion_comment = False) |
Test plan: #72662
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/ref-unsafe-in-iterators-async.md