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

SystemStackError when memoized method calls memoized super method #285

Open
mehanoid opened this issue May 6, 2022 · 2 comments
Open

SystemStackError when memoized method calls memoized super method #285

mehanoid opened this issue May 6, 2022 · 2 comments

Comments

@mehanoid
Copy link

mehanoid commented May 6, 2022

class A
  prepend MemoWise
  memo_wise def answer
    42
  end
end

class B < A
  memo_wise def answer
    super + 1
  end
end

puts B.new.answer

Expected result: "43" is printed
Actual result: SystemStackError is raised

@ms-ati
Copy link
Contributor

ms-ati commented Sep 28, 2022

I made a test case for this (confirming the issue) using the following test.rb:

require "memo_wise"

class A
  prepend MemoWise

  def answer
    42
  end
  memo_wise :answer
end

class B < A
  prepend MemoWise
  
  def answer
    super + 1
  end
  memo_wise :answer
end

puts B.new.answer

@ms-ati
Copy link
Contributor

ms-ati commented Sep 28, 2022

Confirmed that removing memo_wise in the parent class A fixes the problem.

Seems like we are having a name collision between the super and sub method?

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

2 participants