Enforce new grammar rules that scoped keyword must be immediately followed by a type possibly “prefixed” by ref/ref readonly/in/out.#64088
Conversation
…ollowed by a type possibly “prefixed” by `ref`/`ref readonly`/`in`/`out`. Related to dotnet#62039. See also https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-07-27.md and https://github.com/dotnet/csharplang/blob/main/proposals/low-level-struct-improvements.md#syntax
|
@cston, @dotnet/roslyn-compiler Please review |
1 similar comment
|
@cston, @dotnet/roslyn-compiler Please review |
| while (IsParameterModifierExcludingScoped(this.CurrentToken)) | ||
| { | ||
| if (this.CurrentToken.ContextualKind == SyntaxKind.ScopedKeyword) | ||
| if (this.CurrentToken.Kind is SyntaxKind.RefKeyword or SyntaxKind.OutKeyword or SyntaxKind.InKeyword) |
There was a problem hiding this comment.
or SyntaxKind.ReadOnlyKeywordperhaps?
That is not needed for any valid scenario. And it is really questionable if that would add any value for an error scenario. Going as is for now.
|
https://github.com/orgs/dotnet/teams/roslyn-compiler For the second review |
|
@dotnet/roslyn-compiler For the second review |
| { | ||
| SyntaxToken scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false); | ||
|
|
||
| // For local functions, 'scoped' is a modifier in LocalFunctionStatementSyntax |
There was a problem hiding this comment.
Is an error reported if a local function has the scoped modifier? #Resolved
There was a problem hiding this comment.
Is an error reported if a local function has the scoped modifier?
Yes. There is a test for that. ReturnTypeScope in RefFieldTest.cs, for example.
Related to #62039.
See also https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-07-27.md and https://github.com/dotnet/csharplang/blob/main/proposals/low-level-struct-improvements.md#syntax