Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upComparison operators have higher precedence than range operator `..` #22877
Comments
This comment has been minimized.
This comment has been minimized.
|
Pull request #21374 (merged) includes several other relevant xrefs. |
kmcallister
added
the
A-parser
label
Mar 1, 2015
huonw
added
I-nominated
T-libs
T-lang
and removed
T-libs
labels
Jan 8, 2016
This comment has been minimized.
This comment has been minimized.
|
cc @dgrunwald |
This comment has been minimized.
This comment has been minimized.
|
If someone shows an example of something that (1.) currently parses but also that (2.) intuition dictates shouldn't parse, then the lang team would be more likely to be inspired to assign this a higher priority, due to backwards compatibility concerns. As it is right now, if the main problems are cases where things do not parse that one might like to parse, then that is a potentially interesting problem to tackle, but it is not quite as high priority as resolving one of the many potentially backwards-incompatible issues that we have in front of us. |
pnkfelix
removed
the
I-nominated
label
Jan 14, 2016
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium |
rust-highfive
added
the
P-medium
label
Jan 14, 2016
This comment has been minimized.
This comment has been minimized.
|
What do we define as "parses" here? The parser "parses" all of the given examples --- but each one as a different operation! |
This comment has been minimized.
This comment has been minimized.
|
I originally tried to give Giving See #20811 for the original issue about the precedence of |
This comment has been minimized.
This comment has been minimized.
|
@insaneinside from a backward compatibility standpoint, the issue is what might accepted by the end-to-end compile. But you make a good point: it might be possible that by implementing the overloaded operators in a particular way, one might be able to construct an example that gets through the compiler with an unexpected parse today.
Update: also, to be pedantic, the first example didn't parse, right? But this others certainly did. |
brson
added
E-hard
I-wrong
I-needs-decision
P-low
and removed
I-wrong
P-medium
labels
Aug 25, 2016
Mark-Simulacrum
added
the
C-feature-request
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Triage: no changes. Is this even fixable? |
insaneinside commentedFeb 27, 2015
This has the effect of causing parse errors and other weirdness when trying to use a range literal in a comparison.
gives us
Huh? Okay, what about this?
So it looks as though the comparison is being reduced before the range.
More fun:
Never mind the fact that ranges don't implement (Partial)Ord -- the precedence is still wrong here, too. Placing the parentheses on the first range instead of the second properly tells us
(although i'd argue that it should also complain about mismatched types here, as well. ;)