Missing nullability warning for spreads of maybe-null collections #74667
Labels
Area-Compilers
Feature - Collection Expressions
Feature - Nullable Reference Types
Nullable Reference Types
Resolution-Duplicate
The described behavior is tracked in another issue
untriaged
Issues and PRs which have not yet been triaged by a lead
Version Used: 17.11 preview 6
There should be a warning "CS8602 Dereference of a possibly null reference" in the following example, but there is not:
When this code runs, it throws NullReferenceException.
In both https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-12.0/collection-expressions#known-length-translation and https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-12.0/collection-expressions#unknown-length-translation, the translation uses
foreach
over the expression being spread, which would equivalently throw:The text was updated successfully, but these errors were encountered: