Open
Description
Invalid Error Code for Attempted to call something which isn't a function nor a method. - E0618
- Fixing this issue will help gccrs to emit error code similiar to rustc.
- Fixing this issue also help this PR [E0423] expected function, tuple struct or tuple variant, found struct #2432 to emit correct erorr code similiar to rustc.
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)
Metadata
Metadata
Assignees
Type
Projects
Status
To do