Skip to content
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

Amusing and wrong error message #51874

Closed
bjorn3 opened this issue Jun 28, 2018 · 3 comments
Closed

Amusing and wrong error message #51874

bjorn3 opened this issue Jun 28, 2018 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jun 28, 2018

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

@oli-obk oli-obk added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 28, 2018
@estebank
Copy link
Contributor

estebank commented Jun 28, 2018

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

@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Jun 28, 2018
@euclio
Copy link
Contributor

euclio commented Jun 29, 2018

I'm interested in working on this.

@estebank
Copy link
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

euclio added a commit to euclio/rust that referenced this issue Jun 29, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 30, 2018
…estebank

use literal span for concrete type suggestion

Fixes rust-lang#51874.

r? @estebank
kennytm added a commit to kennytm/rust that referenced this issue Jun 30, 2018
…estebank

use literal span for concrete type suggestion

Fixes rust-lang#51874.

r? @estebank
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jul 1, 2018
…estebank

use literal span for concrete type suggestion

Fixes rust-lang#51874.

r? @estebank
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jul 1, 2018
…estebank

use literal span for concrete type suggestion

Fixes rust-lang#51874.

r? @estebank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

4 participants