Skip to content

Can't add f64 + {float} #9

Closed
rust-lang/rust
#109749
@compiler-errors

Description

@compiler-errors
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

Activity

compiler-errors

compiler-errors commented on Mar 30, 2023

@compiler-errors
OwnerAuthor

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

added
needs-fixAn easy fix needs to be put up and applied
and removed
needs-fixAn easy fix needs to be put up and applied
on Mar 30, 2023
added a commit that references this issue on Mar 30, 2023

Rollup merge of rust-lang#109749 - compiler-errors:new-solver-float-v…

e1f4ddf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @compiler-errors

      Issue actions

        Can't add `f64 + {float}` · Issue #9 · compiler-errors/next-solver-hir-issues