Skip to content

Can't infer generic integer constants as floating-point #15674

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
ghost opened this issue Jul 14, 2014 · 1 comment
Closed

Can't infer generic integer constants as floating-point #15674

ghost opened this issue Jul 14, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 14, 2014

fn main() {
    let x: f64 = 2.0;
    println!("{}", x / 2);
}

Returns:

expected `f64` but found `<generic integer #0>` (expected f64 but found integral variable)

Easy fix is to change the 2 to a 2.0, although that seems kind of excessive in this case. It makes more sense to make integer constants generic numbers, like Haskell does, if they're going to be generic.

@ghost ghost changed the title Can't infer generic integer constants as floating-point Can't infer generic integer constants as floating-point (0.11.0) Jul 14, 2014
@emberian emberian changed the title Can't infer generic integer constants as floating-point (0.11.0) Can't infer generic integer constants as floating-point Jul 14, 2014
@thestinger
Copy link
Contributor

Proposals to change language semantics need to go through the RFC process. There happens to be an RFC for this already:

rust-lang/rfcs#183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant