Skip to content

rustc successfully compiles functions with duplicate argument names #7794

Closed
@chris-morgan

Description

@chris-morgan
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions