rust icon indicating copy to clipboard operation
rust copied to clipboard

cannot have static and instance methods with the same name

Open ttaubert opened this issue 13 years ago • 4 comments

This doesn't work:

struct Foo {
  baz: uint
}

impl Foo {
  static fn bar() {
    Foo { baz: 0 }.bar();
  }

  fn bar() {
  }
}

and yields:

error: internal compiler error: calling transform_self_type_for_method on static method

ttaubert avatar Dec 23 '12 18:12 ttaubert

Same error message for:

trait Trait {
  static fn bar();

  fn foo() {
    self.bar();
  }
}

ttaubert avatar Dec 24 '12 00:12 ttaubert

There's still some ambivalence over whether this is a bug or a feature (see the comments on the pull request).

catamorphism avatar Dec 27 '12 23:12 catamorphism

I closed the pull request, and would rather fix this by emitting an error.

brson avatar Jan 14 '13 20:01 brson

This is a proper error message now. I'll add the test case along with my pile of other test cases to add. Closing.

catamorphism avatar Mar 21 '13 19:03 catamorphism