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

Confusing errors for call_method(arg_name: value) when value is not a literal #105810

Closed
asquared31415 opened this issue Dec 17, 2022 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@asquared31415
Copy link
Contributor

Given the following code:

Playground

fn uwu(val: i32) {}

fn main() {
    let x = 1_i32;
    uwu(val: x);
}

The current output is:

error[E0425]: cannot find value `val` in this scope
 --> src/main.rs:5:9
  |
5 |     uwu(val: x);
  |         ^^^ expecting a type here because of type ascription

error[E0573]: expected type, found local variable `x`
 --> src/main.rs:5:14
  |
5 |     uwu(val: x);
  |              ^ expecting a type here because of type ascription

Ideally the output should look like it does when value is a literal, like an integer, float, or string literal

error: invalid `struct` delimiters or `fn` call arguments
 --> src/main.rs:5:5
  |
5 |     uwu(val: x);
  |     ^^^^^^^^^^^^^^^
  |
help: if `uwu` is a struct, use braces as delimiters
  |
5 |     uwu { val: x };
  |         ~        ~
help: if `uwu` is a function, use the arguments directly
  |
5 -     uwu(val: x);
5 +     uwu(x);
  |

Diagnostics reproduce on all of current stable, beta, and nightly:
Stable 1.66.0
Beta 1.67.0-beta.2
Nightly 1.68.0 2022-12-15

@asquared31415 asquared31415 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 17, 2022
@Noratrieb
Copy link
Member

No one should attempt to fix this until my PR where I remove type ascription.

@fmease

This comment was marked as resolved.

@rustbot rustbot added the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label Dec 23, 2022
@fmease
Copy link
Member

fmease commented May 3, 2023

Unblocked by #109128.

@rustbot label -S-blocked

@rustbot rustbot removed the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label May 3, 2023
@jieyouxu
Copy link
Member

On beta it seems to be fixed?

error: invalid `struct` delimiters or `fn` call arguments
 --> test.rs:5:5
  |
5 |     uwu(val: x);
  |     ^^^^^^^^^^^
  |
help: if `uwu` is a struct, use braces as delimiters
  |
5 |     uwu { val: x };
  |         ~        ~
help: if `uwu` is a function, use the arguments directly
  |
5 -     uwu(val: x);
5 +     uwu(x);
  |

error: aborting due to previous error
rustc 1.71.0-beta.1 (eff24c06d 2023-05-29)
binary: rustc
commit-hash: eff24c06d8f4397802b546aa2e52450e1022fc02
commit-date: 2023-05-29
host: x86_64-unknown-linux-gnu
release: 1.71.0-beta.1
LLVM version: 16.0.4

@Noratrieb
Copy link
Member

Tests:

//~^ ERROR invalid `struct` delimiters or `fn` call arguments

let my = monad_bind(mx, T: Try); //~ ERROR invalid `struct` delimiters or `fn` call arguments

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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants