-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
{ | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or SyntaxKind.ReadOnlyKeyword
perhaps?
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 |
@@ -9827,6 +9845,14 @@ private StatementSyntax ParseLocalDeclarationStatement(SyntaxList<AttributeListS | |||
var variables = _pool.AllocateSeparated<VariableDeclaratorSyntax>(); | |||
try | |||
{ | |||
SyntaxToken scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false); | |||
|
|||
// For local functions, 'scoped' is a modifier in LocalFunctionStatementSyntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an error reported if a local function has the scoped modifier? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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