Repository navigation
parser: reject real type suffixes after hexadecimal and binary literals - #52
Merged
Merged
Conversation
A hexadecimal or binary literal accepted the real type suffixes that C# allows only after decimal digits: 0b101d was the double 5, 0b1f a float, and 0b1m and 0x10m decimals. In a hexadecimal literal, d and f are digits, so only m was affected there. Decimal digits followed by d, f, or m are now read as real literals, so only hexadecimal and binary literals reached the suffix handling in AdjustNumericType. Remove it, so that the letter is left after the literal and reported as a syntax error at its position, as in C#.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A hexadecimal or binary literal accepted the real type suffixes
d,f, andm, which C# allows only after decimal digits:0b101d5(Double)(1:6) Expected '(', '[', '.', ':>', ...0b1f1(Single)(1:4) Expected ...0b1m,0x10m1,16(Decimal)(1:4) Expected ...,(1:5) Expected ...C# rejects all of them (CS1003). In a hexadecimal literal,
dandfare digits, so0x1dand0x1Fstay the integers 29 and 31.Since #51, decimal digits followed by
d,f, ormare read as real literals, so only hexadecimal and binary literals reached the suffix handling inAdjustNumericType. This PR removes it;1d,1f, and1mare not affected.Expressions that relied on these suffixes, such as
0x10m, no longer parse.