stack overflow on super
|Target version:||next minor|
|ruby -v:||ruby 1.9.3dev (2010-05-26 trunk 28028) [i686-linux]||Backport:|
It looks like
super behavior is a bit different in 1.8 and 1.9. Please find the example below:
class A < Base
class B < A
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux] output:
and ruby 1.9.3dev (2010-05-26 trunk 28028) [i686-linux] output:
super.rb:9: stack level too deep (SystemStackError)
Hope that helps.
#1 Updated by Marc-Andre Lafortune almost 4 years ago
- Category set to core
- Priority changed from Normal to Low
I thought I had submitted that bug, actually, but seems I forgot!
Just to clarify: this happens when a module appears twice in the list of ancestors. Ruby typically forbids this, but if the module is included in just the right order, it is possible. In the example given, invert the two includes and Override is included only once.
#6 Updated by Shugo Maeda over 1 year ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r36612.
Serge, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- insns.def (invokesuper): don't skip the same class. instead, use rbmethodentrygetwith_omod() to avoid infinite loop when super is used with refinements. [Bug #3351]
#10 Updated by Shugo Maeda over 1 year ago
- Assignee changed from Shugo Maeda to Yukihiro Matsumoto
mame (Yusuke Endoh) wrote:
Shugo-san, ko1, what's the status?
Override#foo is called only once, because in the SVN trunk, if a method found by super is the current method, it's skipped to avoid an infinite loop. The check was introduced for super in a refinement. Without it, super in a refinement causes an infinite loop.
Do you think this issue important?
I don't think so. Can I leave it as is, Matz?