-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Opportunity to improve error message for mistyped inclusive range (..==
)
#86395
Comments
Other test cases, provided by @estebank fn main() {
println!("{:?}", 0..1 == 1);
println!("{:?}", 0.. == 1);
println!("{:?}", 0..== 1);
} |
This is surprisingly complicated in a bunch of ways. The relevant function, at least for the base case, is Now for the problems. First off, implementing this cleanly requires adding at least one new feature to Then there's the whole context sensitivity thing. Dealing with this the way Esteban suggested is way above my pay grade. But you've got to do something, or you can't even handle simple cases like I'm open to advice on whether a minimalist approach might be acceptable, but I'm currently inclined to leave this for someone who actually knows what they're doing. |
@inquisitivecrystal you don't have to add a new method, you use As for the context sensitive checks, you can also use Now, we don't need to address all the cases, we can work incrementally, starting on the low hanging fruit and eventually getting to the "perfect output from the compiler reading my mind". :) |
Thanks, @estebank. That's extraordinarily helpful. I've implemented this, limited to the Now to try this again: |
Wow, well done @inquisitivecrystal. Over time I hope that I can improve things myself. Nice work! |
Given the following code: [playground link]
The current output is:
Ideally the output should look like:
The text was updated successfully, but these errors were encountered: