-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Support using local declarations in a Simple Program.
#42385
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
Support using local declarations in a Simple Program.
#42385
Conversation
|
@cston, @RikkiGibson, @dotnet/roslyn-compiler Please review |
| private bool IsPossibleFirstTypedIdentifierInLocaDeclarationStatement(bool isGlobalScriptLevel) | ||
| { | ||
|
|
||
| bool? typedIdentifier = IsPossibleTypedIdentifierStart(this.CurrentToken, this.PeekToken(1), allowThisKeyword: false); |
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.
Extra blank line. #Resolved
| N(SyntaxKind.EndOfFileToken); | ||
| } | ||
| EOF(); | ||
| } |
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.
} [](start = 8, length = 1)
Consider testing using static type = identifier;. #Resolved
|
@RikkiGibson, @dotnet/roslyn-compiler Please review, need a second sign-off for a fairly small change. |
|
|
||
| if (IsDeclarationModifier(tk)) // treat `const int x = 2;` as a local variable declaration | ||
| { | ||
| if (tk != SyntaxKind.StaticKeyword) // For `static` we still need to make sure we have a typed dentifier after it, because `using static type;` is a valid using directive. |
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.
nit: typed *identifier #Resolved
| } | ||
| } | ||
| else if ((SyntaxFacts.IsPredefinedType(tk) && | ||
| this.PeekToken(1).Kind != SyntaxKind.DotToken && // e.g. `int.Parse()` is an expression |
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.
should this use 'tk' instead? #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.
should this use 'tk' instead?
Good catch, that should peek at the next token instead, i.e. 2.
In reply to: 392430189 [](ancestors = 392430189)
Related to #41704.