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

[E0423] expected function, tuple struct or tuple variant, found struct #2432

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

MahadMuhammad
Copy link
Contributor


Expected function, tuple struct or tuple variant, found struct - E0423

Give error when an identifier was used like a function name or a value was expected and the identifier exists but it belongs to a different namespace.


Code tested from E0423:

// https://doc.rust-lang.org/error_codes/E0423.html
#![allow(unused)]
fn main() {
    struct Foo {
        a: bool,
    };

    let f = Foo(); // { dg-error "expected function, tuple struct or tuple variant, found struct .Foo." }
                   // error: expected function, tuple struct or tuple variant, found `Foo`
                   // `Foo` is a struct name, but this expression uses it like a function name
}

Output:

/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/found_struct.rs:8:13: error: expected function, tuple struct or tuple variant, found struct 'Foo' [E0423]
compiler exited with status 1
PASS: rust/compile/found_struct.rs  (test for errors, line 8)
PASS: rust/compile/found_struct.rs (test for excess errors)

Running Test Cases:

Output:

/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/tuple_struct1.rs:7:13: error: expected function, tuple struct or tuple variant, found struct 'Foo' [E0423]
compiler exited with status 1
PASS: rust/compile/tuple_struct1.rs  (test for errors, line 7)
PASS: rust/compile/tuple_struct1.rs (test for excess errors)

gcc/rust/ChangeLog:

* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): called error function.

gcc/testsuite/ChangeLog:

* rust/compile/found_struct.rs: New test.

…d struct

Give error when an identifier was used like a function
name or a value was expected and the identifier exists
but it belongs to a different namespace.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
	called error function.

gcc/testsuite/ChangeLog:

	* rust/compile/found_struct.rs: New test.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
@philberty philberty added the diagnostic diagnostic static analysis label Jul 17, 2023
@philberty philberty added this to the GCC 14 Stage 3 milestone Jul 17, 2023
@philberty philberty added this pull request to the merge queue Jul 17, 2023
Merged via the queue into Rust-GCC:master with commit d765138 Jul 17, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic diagnostic static analysis
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants