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

[Truffle] Super in an aliased method can confuse the ancestor chain #3604

Closed
chrisseaton opened this issue Jan 19, 2016 · 3 comments
Closed
Assignees
Milestone

Comments

@chrisseaton
Copy link
Contributor

class Foo
  def foo
    puts 'Foo#foo'
  end
end

class Bar < Foo
  def foo
    puts 'Bar#foo'
    super
  end
end

class Dod < Bar
  alias_method :bar, :foo
end

Dod.new.bar

Expected

Bar#foo
Foo#foo

Actual

Bar#foo
Bar#foo
Foo#foo
@chrisseaton chrisseaton added this to the truffle-dev milestone Jan 19, 2016
@eregon
Copy link
Member

eregon commented Jan 19, 2016

The lookup is wrong because the definition module of :bar is Dod. We need to find the proper rules for super lookup, maybe we need to keep track of the actual module where the method was defined and not the module to which the method was attached.

@eregon
Copy link
Member

eregon commented Jan 20, 2016

I took a quick look and it seems that keeping the definition module to be where the method was lexically defined works.

@eregon eregon self-assigned this Jan 20, 2016
@eregon
Copy link
Member

eregon commented Jan 21, 2016

Fixed by dafc460.

@eregon eregon closed this as completed Jan 21, 2016
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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

No branches or pull requests

3 participants