Skip to content

Unexpected inference error #41521

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

Closed
TheJare opened this issue Apr 25, 2017 · 1 comment
Closed

Unexpected inference error #41521

TheJare opened this issue Apr 25, 2017 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-inference Area: Type inference

Comments

@TheJare
Copy link

TheJare commented Apr 25, 2017

An error in the source code causes the correct compile error, but rustc then emits an additional compile error in unrelated, completely correct code.

I tried this code:

fn main() {
for xx in 0..11 { print!("{}", xx as f64) };
kk = 666 // Error here triggers inference error in previous line
}

I expected to see this happen:

error[E0425]: cannot find value `kk` in this scope
 --> <anon>:3:5
  |
3 |     kk = 666
  |     ^^ did you mean `Ok`?

But in addition, this happened too:

error: non-scalar cast: `{integer}` as `f64`
 --> <anon>:2:36
  |
2 |     for xx in 0..11 { print!("{}", xx as f64) };
  |                                    ^^^^^^^^^

If the line containing the legitimate error is removed, the unrelated code compiles correctly as expected, and the additional, incorrect error will no longer show up.

@jdm jdm added the A-diagnostics Area: Messages for errors, warnings, and lints label Apr 26, 2017
@Mark-Simulacrum Mark-Simulacrum added the A-inference Area: Type inference label Jun 22, 2017
@Mark-Simulacrum
Copy link
Member

Closing in favor of #35772.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-inference Area: Type inference
Projects
None yet
Development

No branches or pull requests

3 participants