Skip to content

Can't add f64 + {float} #9

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
compiler-errors opened this issue Mar 29, 2023 · 1 comment · Fixed by rust-lang/rust#109749
Closed

Can't add f64 + {float} #9

compiler-errors opened this issue Mar 29, 2023 · 1 comment · Fixed by rust-lang/rust#109749
Labels
has-fix A fix is up

Comments

@compiler-errors
Copy link
Owner

compiler-errors commented Mar 29, 2023

fn foo(x: f64) {
    let y = x + 1.0;
}
error[E0277]: cannot add `{float}` to `f64`
 --> <source>:2:15
  |
2 |     let y = x + 1.0;
  |               ^ no implementation for `f64 + {float}`
  |
  = help: the trait `Add<{float}>` is not implemented for `f64`
  = help: the following other types implement trait `Add<Rhs>`:
            <&'a f64 as Add<f64>>
            <&f64 as Add<&f64>>
            <f64 as Add<&f64>>
            <f64 as Add>

error: the type `fn(f64, _) -> <f64 as Add<_>>::Output` is not well-formed
 --> <source>:2:15
  |
2 |     let y = x + 1.0;
  |               ^

That WF error is strange.


Probably also fixes: tests/ui/associated-types/issue-18655.rs

@compiler-errors
Copy link
Owner Author

Oh, we were canonicalizing float vars wrong. Easy fix. Phew.

@compiler-errors compiler-errors added needs-fix An easy fix needs to be put up and applied has-fix A fix is up and removed needs-further-investigation Needs to be root-caused needs-fix An easy fix needs to be put up and applied labels Mar 30, 2023
JohnTitor added a commit to JohnTitor/rust that referenced this issue Mar 30, 2023
…ar, r=lcnr

Canonicalize float var as float in new solver

Typo in new canonicalizer -- we should be canonicalizing float vars as `CanonicalTyVarKind::Float`, not `CanonicalTyVarKind::Int`.

Fixes compiler-errors/next-solver-hir-issues#9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-fix A fix is up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant