dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.75k stars 3.99k forks source link

Nullable reference types and array of multidimensional arrays - error CS0029 #50967

Open gurustron opened 3 years ago

gurustron commented 3 years ago

From this SO question

Version Used:

Steps to Reproduce:

sharplab

string[][] a = new string[1][];
string?[]?[] b = new string[1][];
string?[]?[]? c = new string[1][];
string?[,][] d = new string[1,2][];
string?[,][]? e = new string[1,2][];
string?[,]?[] f = new string[1,2][];   // compiler error

Expected Behavior:

Compiles

Actual Behavior:

Compilation error :

error CS0029: Cannot implicitly convert type 'string[,][]' to 'string?[,]?[]'

gurustron commented 1 year ago

@jaredpar Also this SO question seems to be pointing in some other similar problems with NRT + jagged arrays combination.