Skip to content

rustc successfully compiles functions with duplicate argument names #7794

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

Closed
chris-morgan opened this issue Jul 15, 2013 · 4 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@chris-morgan
Copy link
Member

fn foo(a: int, a: bool) {
    println(fmt!("%?", a));
}
fn main() {
    foo(42, false);
}

I expect this to fail to compile on account of the duplicated argument name. Instead:

<anon>:1:7: 1:8 warning: unused variable: `a` [-W unused-variable (default)]
<anon>:1 fn foo(a: int, a: bool) {
                ^

And running it writes false. The first argument is wholly inaccessible.

@huonw
Copy link
Member

huonw commented Sep 10, 2013

Triage: still an issue.

@sanxiyn
Copy link
Member

sanxiyn commented Feb 5, 2014

Still an issue. Ping @cmr.

@ghost
Copy link

ghost commented Sep 26, 2014

Seems like a dupe of #17568 (which is a superset of this issue, hence this one should be closed).

@ghost
Copy link

ghost commented Nov 10, 2014

And as #17568 is now fixed, I'm closing this.

@ghost ghost closed this as completed Nov 10, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 21, 2021
Fix false positive when `Drop` and `Copy` involved in `field_reassign_with_default` lint

Fix FP in `field_reassign_with_default` lint when type implements `Drop` but not all fields are `Copy`.

fixes: rust-lang#6312

changelog: [`field_reassign_with_default`] Fix FP when `Drop` and `Copy` are involved
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

3 participants