bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.56k stars 102 forks source link

[zerolib] Span<T> is readonly #142

Closed lucabol closed 5 months ago

lucabol commented 5 months ago

Repro:

using System;

char[] chars = new char[10];
Span<char> sc = new Span<char>(chars);
sc[0] = 'a';

This gives:

SpanBug.cs(5,1): error CS8331: Cannot assign to property 'this' or use it as the right hand side of a ref assignment because it is a readonly variable

This is likely because in zero lib Span.cs on line 70 the index is marked as readony:

         public ref readonly T this[int index]

I would submit a PR, but not sure how to test that my hypothesis is correct.