You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This doesn't work since script variables are not stack allocated:
>varspan=newbyte[]{1,2,3}.AsSpan();(1,1): error CS8345:Fieldorauto-implemented property cannot be of type 'Span<byte>' unless it is an instance member of a refstruct.
This is by design, the message could be better though (something like Script variables cannot be of type 'Span<byte>'.).
We should parse the declaration and report semantic error.
This doesn't work since top-level code is implicitly async:
>{.varspan=newbyte[]{1,2,3}.AsSpan();.}(2,5): error CS4012:Parametersor locals of type 'Span<byte>' cannot be declared inasyncmethodsor lambda expressions.
Is there a reason why this can't be allowed for variables that do not need to be hoisted? Is it just to simplify handling of these cases?
If we don't make this work we should report a better error message (e.g. Locals of type 'Span<byte>' cannot be declared outside of methods in scripts.).
BTW, one can still work with spans in interactive, they just need to be declared within a method:
>voidF().{.varspan=newbyte[]{1,2,3}.AsSpan();..}
The text was updated successfully, but these errors were encountered:
This doesn't work since script variables are not stack allocated:
This is by design, the message could be better though (something like
Script variables cannot be of type 'Span<byte>'.
).Similarly for ref locals:
We should parse the declaration and report semantic error.
This doesn't work since top-level code is implicitly async:
Is there a reason why this can't be allowed for variables that do not need to be hoisted? Is it just to simplify handling of these cases?
If we don't make this work we should report a better error message (e.g.
Locals of type 'Span<byte>' cannot be declared outside of methods in scripts.
).BTW, one can still work with spans in interactive, they just need to be declared within a method:
The text was updated successfully, but these errors were encountered: