-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Reports "not all control paths return a value" when that's not true #1905
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
Comments
This is a limitation of typestate -- the compiler doesn't know that the while loop in yes_no_prompt is infinite, because it doesn't treat the literal I have argued before (and I wasn't the only one) that this is a case for adding an infinite-loop construct so you could write I'm going to close this issue, but open a new RFC for the infinite-loop construct. |
That works. I believe gcc has a similar problem with this construct, but I've seen C/C++ compilers that are able to handle this (which has caused problems when one compiler requires the return value, and one didn't). If you could post the RFC here after making it so I can keep track of it, that would be great. |
Yup, the RFC is #1906 -- I believe that some Java compilers also special-case Also, perhaps obvious, but the workaround for this (requiring no changes to the compiler) is to put either a |
…tions (rust-lang#2967) This PR is the next step to rework/introduce the `should_panic`/`fail_uncoverable` options as global conditions. Until now, we haven't had a concrete proposal to do so other than the implementation in rust-lang#2532. This PR presents one for each option in their respective RFCs. I'd like to agree on this design before starting the code review for rust-lang#2532. Related to rust-lang#1905 rust-lang#2272 rust-lang#2299 rust-lang#2516
The following code fragment returns the following from the compiler:
The control paths for this function should be fine. Putting "fail" at the end causes the compiler to work fine, but I haven't been able to find an input that causes it to fail.
The text was updated successfully, but these errors were encountered: