Replies: 1 comment 6 replies
-
@ltcmelo It's unclear what you're asking for here. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The
foreach
statement is specified by means of an expansion into awhile
*.But the specification doesn't apply for a type such as
System.Span
orSystem.ReadOnlySpan
as the expansion will produce invalid code.Specifically: the
V
inforeach (V v in x) «embedded_statement»
will expand into theV
inV v = (V)(T)e.Current;
; however, if theforeach
is inside anasync
method, then the declarationV v
will lead to a diagnose such as:error CS4012: Parameters or locals of type 'ReadOnlySpan<char>' cannot be declared in async methods or async lambda expressions.
Here's an example in which specified expansion breaks.
* I have (most of) this expansion as a syntax rewriter.
Beta Was this translation helpful? Give feedback.
All reactions