Skip to content

Amusing and wrong error message #51874

Closed
Closed

Description

@bjorn3
fn main() {
    let a = (1.0).pow(1.0);
}
error[E0689]: can't call method `pow` on ambiguous numeric type `{float}`
 --> src/main.rs:2:19
  |
2 |     let a = (1.0).pow(1.0);
  |                   ^^^
help: you must specify a concrete type for this numeric value, like `f32`
  |
2 |     let a = (1.0)_f32.pow(1.0);
  |             ^^^^^^^^^

Please note the (1.0)_f32

Activity

  1. estebank commented on Jun 28, 2018

    @estebank
    Contributor

    The literal's span should point inside the parenthesis. Probably needs a change to parse_lit_token in libsyntax/parser/parse.rs.

  2. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
    on Jun 28, 2018
  3. euclio commented on Jun 29, 2018

    @euclio
    Contributor

    I'm interested in working on this.

  4. estebank commented on Jun 29, 2018

    @estebank
    Contributor

    @euclio feel free to reach out for any help you might need!

    I believe that you should verify if changing the span being used in the AST for literals changes the suggestion output. If it doesn't, it means that the problem is not at the parser level, but when lowering to HIR. If that is the case, we need to dig deeper, but I'll be here to help you with that.

    https://forge.rust-lang.org/x-py.html

  5. added a commit that references this issue on Jun 29, 2018
    28c4813
  6. added a commit that references this issue on Jun 30, 2018
    b50a6ba
  7. added a commit that references this issue on Jun 30, 2018
    7d8831e
  8. added 2 commits that reference this issue on Jul 1, 2018
    7703160
    3f5d2fd
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

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions