Skip to content

Commit 51c8f3c

Browse files
authored
Address upcoming breaking change for span-valued collection expressions (#120771)
[Doc for upcoming breaking change](https://github.com/dotnet/roslyn/blob/copilot/fix-safecontext-of-span-collection/docs/compilers/CSharp/Compiler%20Breaking%20Changes%20-%20DotNet%2011.md#the-safe-context-of-a-collection-expression-of-spanreadonlyspan-type-is-now-declaration-block) See dotnet/roslyn#80684. TensorShape's constructor was the only break I found when compiling the libraries. I fixed this by extracting the collection-expression to the top level.
1 parent e6fbfa2 commit 51c8f3c

File tree

1 file changed

+2
-2
lines changed
  • src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore

1 file changed

+2
-2
lines changed

src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorShape.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ internal enum TensorFlags : uint
6868
private TensorShape(nint linearLength, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, TensorFlags flags)
6969
{
7070
int rank = lengths.Length;
71-
71+
ReadOnlySpan<nint> rank0Lengths = [0];
7272
if (rank == 0)
7373
{
74-
lengths = [0];
74+
lengths = rank0Lengths;
7575
rank = 1;
7676
}
7777
Debug.Assert(rank >= 1);

0 commit comments

Comments
 (0)