Open cston opened 11 months ago
There is a similar issue when populating an array or span from a collection expression with spread elements of known length. In those cases, a local is used for all elements, even though we could use constants for the elements before the first spread (for instance, for assigning x
and y
in the following - see sharplab.io).
static void CreateArray(int x, int y, int[] a, int z)
{
int[] b = [x, y, ..a, z];
}
Originally posted by @Sergio0694 in https://github.com/dotnet/roslyn/issues/70656#issuecomment-1847043026