-
Notifications
You must be signed in to change notification settings - Fork 4k
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 ref-like locals in iterators and async methods #72664
Allow ref-like locals in iterators and async methods #72664
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). |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Should the error location be stackalloc int[] { 1, 2, 3 }
rather than the containing block? #WontFix
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.
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() |
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.
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