Allow digit separator after base specifier#20449
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.
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.
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.
Please test with multiple underscores. @gafter can confirm expected language/spec behavior. #Resolved
There was a problem hiding this comment.
| underscoreInWrongPlace = true; | ||
| if (isHex || isBinary) | ||
| { | ||
| CheckFeatureAvailability(MessageID.IDS_FeatureLeadingDigitSeparator); |
There was a problem hiding this comment.
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.
Same test suggestions for VB. Thanks #Resolved
jcouv
left a comment
There was a problem hiding this comment.
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.
Consider switching order: if (firstCharWasUnderscore) { ... } else if (lastCharWasUnderscore) { ... }.
#Resolved
There was a problem hiding this comment.
Please add tests for 1E+_2, 1E-_2, and 1E_. #Resolved
ece5c60 to
a1395e3
Compare
There was a problem hiding this comment.
Unnecessary parentheses around entire Boolean expression, here and below.
There was a problem hiding this comment.
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.
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.
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
| @@ -2085,13 +2095,16 @@ FullWidthRepeat2: | |||
|
|
|||
| If Overflows Then | |||
There was a problem hiding this comment.
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?
|
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