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

Can define a associated type more than once #23969

Closed
Kimundi opened this issue Apr 2, 2015 · 3 comments
Closed

Can define a associated type more than once #23969

Kimundi opened this issue Apr 2, 2015 · 3 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-type-system Area: Type system P-medium Medium priority

Comments

@Kimundi
Copy link
Member

Kimundi commented Apr 2, 2015

trait Foo {
    type Ty;
}

impl Foo for () {
    type Ty = ();
    type Ty = usize;
}

fn main() { 
    let _: <() as Foo>::Ty = ();
}

This erroneously parses and compiles fine, the compiler seems to use the first definition of Ty in the impl.

This might have been introduced by #23265, ping @eddyb.

@Kimundi Kimundi added the A-parser Area: The parsing of Rust source code to an AST label Apr 2, 2015
@alexcrichton
Copy link
Member

triage: I-nominated

@nikomatsakis nikomatsakis added the A-associated-items Area: Associated items (types, constants & functions) label Apr 2, 2015
@nrc nrc added A-associated-items Area: Associated items (types, constants & functions) and removed A-associated-items Area: Associated items (types, constants & functions) A-parser Area: The parsing of Rust source code to an AST labels Apr 2, 2015
@pnkfelix
Copy link
Member

pnkfelix commented Apr 2, 2015

classifying as just a bug. P-backcompat-lang, not 1.0 blocker.

@brson brson added P-medium Medium priority A-type-system Area: Type system and removed P-backcompat-lang labels Apr 24, 2015
@brson
Copy link
Contributor

brson commented Apr 24, 2015

Demoting this to P-medium. Somebody should get on it though!

nham pushed a commit to nham/rust that referenced this issue Jun 3, 2015
nham pushed a commit to nham/rust that referenced this issue Jul 15, 2015
Expands E0201 to be used for any duplicate associated items, not just duplicate
methods/functions. It also correctly detects when two different kinds of items
(like a constant and a method) have the same name.

Fixes rust-lang#23969.
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 17, 2015
Adds two error codes, one for duplicate associated constants and one for types. I'm not certain these should each have their own code, but E0201 is already solely for duplicate associated functions so at least it kinda matches. This will lead to somewhat redundant error explanations, but that's nothing new!

Fixes rust-lang#23969.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-type-system Area: Type system P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

7 participants