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

Inheritance on self doesn't work right in default methods #3979

Closed
catamorphism opened this issue Nov 16, 2012 · 6 comments
Closed

Inheritance on self doesn't work right in default methods #3979

catamorphism opened this issue Nov 16, 2012 · 6 comments
Labels
A-traits Area: Trait system
Milestone

Comments

@catamorphism
Copy link
Contributor

This should work:

trait Positioned {
  fn SetX(int);
}

trait Movable: Positioned {
  fn translate(dx: int) {
    self.SetX(self.X() + dx);
  }
}

It fails to typecheck:

src/test/run-pass/issue-2616.rs:13:4: 13:13 error: attempted access of field `SetX` on type `self`,
but no field or method with that name was found
/Users/tchevalier/rust2/src/test/run-pass/issue-2616.rs:13     self.SetX(self.X() + dx);
@catamorphism
Copy link
Contributor Author

I've almost fixed this -- I just ran into another incomplete bit of code in trans that I want to fix too.

@ghost ghost assigned catamorphism Dec 24, 2012
catamorphism added a commit to catamorphism/rust that referenced this issue Jan 21, 2013
Add a new method_super origin for supertrait methods. Also make
coherence create a table that maps pairs of trait IDs and self types
to impl IDs, so that it's possible to check a supertrait method
knowing only its index in its trait's methods (without knowing all
supertraits for a given trait).

As per rust-lang#3979
@jbclements
Copy link
Contributor

@catamorphism : there's a test for this, issue-3979-generics.rs. It had bit-rotted a bit, but after replacing impl Ty : Tr with impl Tr for Ty, I'm now getting an ICE. Should I re-open this bug, or is this an unrelated bug?

@catamorphism
Copy link
Contributor Author

@jbclements Reopen or open a new bug if you're not sure it's the same ICE, either way :-)

@jbclements
Copy link
Contributor

On Apr 18, 2013, at 2:39 PM, Tim Chevalier wrote:

@jbclements Reopen or open a new bug if you're not sure it's the same ICE, either way :-)

Decisions, darn it, I want decisions! :)

Ah well.

John

@catamorphism
Copy link
Contributor Author

Well, I didn't see the error, and recreating it would require effort ;-)

@catamorphism
Copy link
Contributor Author

(so I don't know whether or not it's the same error)

@catamorphism catamorphism removed their assignment Jun 16, 2014
RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 27, 2024
…fJung

tail_calls: add test ensuring local vars are indeed gone

Ensure that local variables get deallocated before the callee gets tail-called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system
Projects
None yet
Development

No branches or pull requests

2 participants