-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix bug when trailing and leading underscores are not the same #22141
Conversation
@@ -1198,7 +1196,10 @@ private bool ScanNumericLiteral(ref TokenInfo info) | |||
default: | |||
if (string.IsNullOrEmpty(valueText)) | |||
{ | |||
this.AddError(MakeError(ErrorCode.ERR_InvalidNumber)); | |||
if (!underscoreInWrongPlace) |
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.
If we don't do this 0x_
produces two errors. (is there any way to handle it somewhere else?)
@@ -2815,6 +2815,17 @@ public void TestNumericWithBadUnderscores() | |||
Assert.Equal("error CS1013: Invalid number", errors[0].ToString(EnsureEnglishUICulture.PreferredOrNull)); | |||
Assert.Equal(text, token.Text); | |||
|
|||
text = "0x_2_"; | |||
token = LexToken(text, _options72); |
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 a corresponding test for VB. #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.
Added. #Resolved
if (usedUnderscore) | ||
else if (firstCharWasUnderscore) | ||
{ | ||
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.
Consider moving the new CheckFeatureAvailability call into the hex/binary condition.
Or, if this call can affect other scenarios than hex/binary, then let's ensure those code paths have test coverage too. 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.
Then we would still need to check !firstCharWasUnderscore
to not get cascading feature errors.
d3b8800
to
f8872c0
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.
LGTM Thanks
test windows_debug_vs-integration_prtest please |
test windows_release_vs-integration_prtest please |
@jcouv Can you please approve for 15.5? This is fixing a regression that was introduced when implementing the "permit leading underscore after base specifier" feature. The current code base permits |
Approved for ask mode |
* dotnet/master: (35 commits) removed unused options (dotnet#22389) Make readonlyness of ref-ternary the AND of operands (dotnet#22384) Refine parsing look-ahead for type arguments (dotnet#22102) IDE Features fix for code generation for ref-readonly (dotnet#22285) Added tests for `out` and `ref` completion in local function Record "allow digit separator after 0b or 0x" (dotnet#22371) Responded to feedback Don't show snippets in VB comments Fix bug when trailing and leading underscores are not the same (dotnet#22141) Add breaking change doc for TypedReference delegate conversion. (dotnet#22084) Add no-PDB-path test for VB Ref ternary shoudl be shielded form optimization in the containing expression that may expose it to mutations Improve method type argument inference around tuples and address backwards compatibility break. (dotnet#22295) Added couple more tests Add unit tests for IStopStatement and IEndStatement and make the APIs public again (dotnet#22225) Revert changes to compilers.sln Support for object initializers. supports all expressions in escape analysis that can possibly produce ref-like values Update tests after merge. Add an option to disable name suggestions ...
Report
0x_2_
as an invalid number.(VB does report it correctly)