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

Invalid Error Code for Attempted to call something which isn't a function nor a method. [E0618] #2434

Open
MahadMuhammad opened this issue Jul 17, 2023 · 0 comments
Labels

Comments

@MahadMuhammad
Copy link
Contributor

MahadMuhammad commented Jul 17, 2023

Invalid Error Code for Attempted to call something which isn't a function nor a method. - E0618


I tried this code from E0618:

// https://doc.rust-lang.org/error_codes/E0618.html
#![allow(unused)]
fn main() {
enum X {
    Entry,
}

X::Entry(); // error: expected function, tuple struct or tuple variant,
            // found `X::Entry`

// Or even simpler:
let x = 0i32;
x(); // error: expected function, tuple struct or tuple variant, found `i32`
}

I expected to see this happen:

  • Give error code similiar to rustc i.e. E0618,
➜  gccrs-build rustc ../mahad-testsuite/E0618.rs
error[E0618]: expected function, found enum variant `X::Entry`
 --> ../mahad-testsuite/E0618.rs:8:1
  |
5 |     Entry,
  |     ----- enum variant `X::Entry` defined here
...
8 | X::Entry(); // error: expected function, tuple struct or tuple variant,
  | ^^^^^^^^--
  | |
  | call expression requires function
  |
help: `X::Entry` is a unit enum variant, and does not take parentheses to be constructed
  |
8 - X::Entry(); // error: expected function, tuple struct or tuple variant,
8 + X::Entry; // error: expected function, tuple struct or tuple variant,
  |

error[E0618]: expected function, found `i32`
  --> ../mahad-testsuite/E0618.rs:13:1
   |
12 | let x = 0i32;
   |     - `x` has type `i32`
13 | x(); // error: expected function, tuple struct or tuple variant, found `i32`
   | ^--
   | |
   | call expression requires function

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0618`.

Instead, this happened:

  • It gives different error code. E0425
➜  gccrs-build gcc/crab1 ../mahad-testsuite/E0618.rs 
../mahad-testsuite/E0618.rs:8:1: error: expected function, tuple struct or tuple variant, found struct ‘X[E0423]
    8 | X::Entry(); // error: expected function, tuple struct or tuple variant,
      | ^
../mahad-testsuite/E0618.rs:13:1: error: Failed to resolve expression of function call
   13 | x(); // error: expected function, tuple struct or tuple variant, found `i32`
      | ^

Analyzing compilation unit

Time variable                                   usr           sys          wall           GGC
 TOTAL                              :   0.00          0.00          0.00          146k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

Originally posted by @MahadMuhammad in #2433 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant