Support for chained comparisons#713
Merged
Merged
Conversation
… suffixed expressions
Contributor
|
This will cause a merge conflict for my IDE changes where I fixed the position of suffixed stuff too 😢 |
Contributor
Author
Ah crap :/ |
Contributor
|
At least I've essentially already done a good review for that part and I can compare our two solutions :P |
Contributor
|
@marcoeilers looks good, I cleaned up some things up in the PR. If you're happy with my changes then we can merge |
JonasAlaif
approved these changes
Jul 13, 2023
Merged
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.
This PR adds support for chained comparisons as syntactic sugar.
I.e.,
e1 < e2 <= e3 > e4can now be parsed and will be desugared to(e1 < e2) && (e2 <= e3) && (e3 > e4).The AST and ParseAST are unchanged.
Note that the
inoperator has the same behavior as the usual comparisons, so you can also writes1 in s2 in s3.Parentheses can be used to force different parsing; e.g.
(e1 < e2) <= e3would not be seen as a chained comparison and would thus result in a type error (since there is a boolean value on the left hand side of a<=operator).Additionally, this PR fixes the positions reported for other suffixed expressions. E.g., the position Viper reported for the expression
e + e2used to be the position of just the+ e2part (i.e., the suffix), without the first operand. Same for e.g.e.f.Additionally, this PR adds a deprecation warning when the
Rationaltype is used.