Skip to content

Multiple params in the same param list with the same name are accepted #17568

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
ben0x539 opened this issue Sep 26, 2014 · 2 comments · Fixed by #17880
Closed

Multiple params in the same param list with the same name are accepted #17568

ben0x539 opened this issue Sep 26, 2014 · 2 comments · Fixed by #17880
Milestone

Comments

@ben0x539
Copy link
Contributor

Both type and value parameters. This compiles just fine, short of the unused-variable warnings:

fn f<T, T>(t: T, t: T) {}

That seems like a fairly useless feature, I imagine people would only ever do this by accident and then get fairly confused about why the "wrong" parameter is being used, if they somehow don't run into type errors. So I am posting this here in the hope it is a bug and not something that needs an RFC to be fixed.

This is half a duplicate of #15969 but not a duplicate of the issue that is a duplicate of, imo.

@huonw
Copy link
Member

huonw commented Sep 26, 2014

Nominating; looks like a back-compat issue.

@pnkfelix
Copy link
Member

pnkfelix commented Oct 2, 2014

P-backcompat-lang, 1.0.

@pnkfelix pnkfelix added this to the 1.0 milestone Oct 2, 2014
pcwalton added a commit to pcwalton/rust that referenced this issue Oct 9, 2014
parameter list.

This breaks code like:

    fn f(a: int, a: int) { ... }
    fn g<T,T>(a: T) { ... }

Change this code to not use the same name for a parameter. For example:

    fn f(a: int, b: int) { ... }
    fn g<T,U>(a: T) { ... }

Code like this is *not* affected, since `_` is not an identifier:

    fn f(_: int, _: int) { ... } // OK

Closes rust-lang#17568.

[breaking-change]
bors added a commit that referenced this issue Oct 9, 2014
…list, r=alexcrichton

parameter list.

This breaks code like:

    fn f(a: int, a: int) { ... }
    fn g<T,T>(a: T) { ... }

Change this code to not use the same name for a parameter. For example:

    fn f(a: int, b: int) { ... }
    fn g<T,U>(a: T) { ... }

Code like this is *not* affected, since `_` is not an identifier:

    fn f(_: int, _: int) { ... } // OK

Closes #17568.

r? @alexcrichton 
[breaking-change]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants