-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Allow digit separator after base specifier #20449
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
Conversation
a7227bc to
8d7fb2b
Compare
|
Ping @gafter since he's the LDM champion for that proposal. |
|
@gafter Did we get approval from LDM on this already? |
|
Neal confirmed that LDM approved the feature. Let's go ahead with review. |
| underscoreInWrongPlace = true; | ||
| if (isHex || isBinary) | ||
| { | ||
| // TODO(leading-digit-separator): check feature flag |
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.
We don't let new TODOs into the master branch.
Blockers should be addressed. Non-blockers should be tracked with a github issue.
jcouv
left a comment
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.
Please address the TODOs (ie adding a feature flag). Thanks
|
failure: Microsoft.CodeAnalysis.Editor.UnitTests.Structure.StructureTaggerTests.OutliningTaggerTooltipText (details) FYI @dotnet/roslyn-infrastructure |
|
|
||
| [Fact] | ||
| [Trait("Feature", "Literals")] | ||
| public void TestNumericWithLeadingUnderscores() |
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.
Please test with multiple underscores. @gafter can confirm expected language/spec behavior. #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.
| underscoreInWrongPlace = true; | ||
| if (isHex || isBinary) | ||
| { | ||
| CheckFeatureAvailability(MessageID.IDS_FeatureLeadingDigitSeparator); |
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 lastCharWasUnderscore be set to true?
Test 0x_1 with language version prior to IDS_FeatureDigitSeparator. I think usedUnderscore should be left unset (no need for cascading feature error)
| Assert.Equal(SyntaxKind.IntegerLiteralToken, tk.Kind) | ||
| Assert.Equal(LiteralBase.Octal, tk.GetBase()) | ||
| Assert.Equal(&O1, tk.Value) | ||
| Assert.Equal(" &O_1 ", tk.ToFullString()) |
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.
Same test suggestions for VB. Thanks #Resolved
jcouv
left a comment
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.
Ping the roslyn-compiler alias for review when feedback addressed. I will be away for some time.
Thanks
|
@dotnet/roslyn-compiler for review (community contribution, approved by LDM already). Thanks |
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.
Consider switching order: if (firstCharWasUnderscore) { ... } else if (lastCharWasUnderscore) { ... }.
#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.
Please add tests for 1E+_2, 1E-_2, and 1E_. #Resolved
ece5c60 to
a1395e3
Compare
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.
Unnecessary parentheses around entire Boolean expression, here and below.
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.
Consider assigning False here since the value is not explicitly initialized any more. Also, there are several cases below where the value is assigned UnderscoreInWrongPlace = UnderscoreInWrongPlace Or (Peek(Here - 1) = "_"c) where UnderscoreInWrongPlace is initially False. (In short, the UnderscoreInWrongPlace Or is unnecessary.)
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.
In short, the UnderscoreInWrongPlace Or is unnecessary.
Yeah, crossed my mind, shouldn't VB flag those cases in the first place?
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.
With ElseIf rather than If we're no longer reporting both overflow and feature-not-available errors (e.g.: compiling Dim x = &H123_456_789_ABC_DEF_123 with -langversion:14). We should report both errors in such cases since the errors are independent.
a1395e3 to
66f98ba
Compare
66f98ba to
4bad4d7
Compare
| Throw ExceptionUtilities.UnexpectedValue(literalKind) | ||
| End Select | ||
|
|
||
| If Overflows Then |
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.
FYI The order is now in sync with C#, an interesting case is an overflowing integer with a trailing underscore which gives 1 and 2 errors in VB and C# respectively. This is now fixed.
Any other case that needs to be verified here?
jcouv
left a comment
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.
LGTM Thanks
Ping @cston
|
Merged. Thanks @alrz For cleaner history, it would have been even better to rebase and squash your branch, rather than merging latest master. But given that the PR only has a couple of commit, it's not crucial (I merged without squashing, because of the merge from master). |
Proposal: dotnet/csharplang#65