You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0308]: mismatched types
--> src/main.rs:4:9
|
4 | foo(10);
| ^^ expected f64, found integral variable
|
= note: expected type `f64`
found type `{integer}`
This error message tells you that the types are mismatched, but doesn't fully explain why. To fix it, you need to use a floating point literal instead of an integer literal. This isn't clear from the error message.
If you're new to programming or if you come from a language that doesn't draw the same distinction between integer and floating point literals, it may not be clear why the literal 10 is not the same as 10.0.
It would be great if we could add something in our error message that would suggest one or more of the valid ways to fix this:
10.0
10.
10f64 - type could be f32 in another context
The text was updated successfully, but these errors were encountered:
sunjay
changed the title
"integral variable" should suggest how to make literal a float
"integral variable" error should suggest how to make literal a float
Aug 12, 2018
…ation_device, r=estebank
wherein we suggest float for integer literals where a float was expected
@sunjay pointed out that this is a nice thing that we could do.
Resolvesrust-lang#53280.
r? @estebank
The following code:
Produces the following error message:
This error message tells you that the types are mismatched, but doesn't fully explain why. To fix it, you need to use a floating point literal instead of an integer literal. This isn't clear from the error message.
If you're new to programming or if you come from a language that doesn't draw the same distinction between integer and floating point literals, it may not be clear why the literal
10
is not the same as10.0
.It would be great if we could add something in our error message that would suggest one or more of the valid ways to fix this:
10.0
10.
10f64
- type could bef32
in another contextThe text was updated successfully, but these errors were encountered: