Can declare two methods with the same name and different arguments #3099

Closed
Emm opened this Issue Aug 3, 2012 · 3 comments

Comments

Projects
None yet
3 participants
@Emm

Emm commented Aug 3, 2012

fn a(x: ~str) -> ~str {
    #fmt("First function with %s", x)
}

fn a(x: ~str, y: ~str) -> ~str {
    #fmt("Second function with %s and %s", x, y)
}

fn main() {
    #info("Result: ");
}

Compiles with a recent rust master (899400c) (but using a(x: ~str) does not compile)

@ghost ghost assigned catamorphism Aug 3, 2012

@Dretch

This comment has been minimized.

Show comment
Hide comment
@Dretch

Dretch Aug 6, 2012

Contributor

You can also declare different types with the same name. This compiles and runs:

enum x {}

trait x {}

type x = int;

struct x { a: int; }

fn main() {
    let x:x = fail;
}
Contributor

Dretch commented Aug 6, 2012

You can also declare different types with the same name. This compiles and runs:

enum x {}

trait x {}

type x = int;

struct x { a: int; }

fn main() {
    let x:x = fail;
}
@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism Aug 6, 2012

Contributor

I'm working on fixing both of these issues.

Contributor

catamorphism commented Aug 6, 2012

I'm working on fixing both of these issues.

@Dretch

This comment has been minimized.

Show comment
Hide comment
@Dretch

Dretch Aug 6, 2012

Contributor

Thats great @catamorphism, thanks!

Contributor

Dretch commented Aug 6, 2012

Thats great @catamorphism, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment