-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Allow foreach on typed null enumerables #80783
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
Changes from all commits
c83025b
0b49420
570e4da
987f561
2f4f633
7f1c97c
2e8018b
da68821
6145ef9
48965b2
5ff37ef
9ba39fe
75f4070
ed2f6ee
a1afaba
99001f8
431b3fb
e170275
c41ee21
74c24ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9929,11 +9929,7 @@ public static async Task Main() | |
| } | ||
| }"; | ||
| CreateCompilationWithTasksExtensions(new[] { source, AsyncStreamsTypes }, parseOptions: TestOptions.Regular9) | ||
| .VerifyDiagnostics( | ||
| // (9,33): error CS0186: Use of null is not valid in this context | ||
| // await foreach (var i in (IAsyncEnumerable<int>)null) | ||
| Diagnostic(ErrorCode.ERR_NullNotValid, "(IAsyncEnumerable<int>)null").WithLocation(9, 33) | ||
| ); | ||
| .VerifyEmitDiagnostics(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be even better to verify execution (throws NRE). Comment also applies to other tests that no longer have errors
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot can you figure out how tests validate that they throw at runtime, and update all the passing tests to then run and demonstrate that they do crash with a NullReferenceException as expected.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will consider in followup. |
||
| } | ||
|
|
||
| [Fact] | ||
|
|
@@ -9956,11 +9952,7 @@ public static async Task Main() | |
| public IAsyncEnumerator<int> GetAsyncEnumerator() => throw null; | ||
| }"; | ||
| CreateCompilationWithTasksExtensions(new[] { source, AsyncStreamsTypes }, parseOptions: TestOptions.Regular9) | ||
| .VerifyDiagnostics( | ||
| // (9,33): error CS0186: Use of null is not valid in this context | ||
| // await foreach (var i in (C)null) | ||
| Diagnostic(ErrorCode.ERR_NullNotValid, "(C)null").WithLocation(9, 33) | ||
| ); | ||
| .VerifyEmitDiagnostics(); | ||
| } | ||
|
|
||
| [Fact] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
@copilot if there is only one usage of ReportConstantNullCollectionExpr left, can you inline it into that final location please. #Closed
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.
Done in commit 2e8018b. Inlined the method since it was only used in one place.