Let the smallest Int be written down - #928
Merged
Merged
Conversation
`-9223372036854775808` is one literal now. It could not be before, and the reason was real rather than an oversight: negation is an operator everywhere else in this language, so a digit run is decoded on its own, and the digits of the smallest `Int` are one past the largest. A clause about the edge had to spell it `0 - 9223372036854775807 - 1`, and the message said so. The split is where it belongs. Whether the minus in front of those digits is the unary one is a question about the grammar, not about lexing, so the lexer hands them over as `TokenKind::IntAtLimit` and says nothing. The parser folds the pair, and reports the digits standing alone. Everything larger is still the lexer's, still one message, still with a stand-in token so the parser has an expression and nothing to add. `Int.min` is still the better thing to write and is still what the message points at. What changed is that the language can now say its own smallest number in the notation it uses for every other one. The two ends of the range are in `agreement.rs`, so neither engine gets to negate a number that does not exist.
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.
-9223372036854775808 is one literal now.
The reason it could not be was real: negation is an operator everywhere else, so a digit run is decoded on its own and the digits of the smallest Int are one past the largest. A clause about the edge had to spell it 0 - 9223372036854775807 - 1.
The split is where it belongs. Whether the minus in front is the unary one is a question about the grammar, so the lexer hands the digits over as TokenKind::IntAtLimit and says nothing; the parser folds the pair and reports the digits standing alone. Everything larger is still the lexer's, still one message.
Int.min is still the better thing to write and is still what the message points at. agreement.rs carries both ends of the range.