Bug #7643

call to super in define_method in refine results in stack level too deep

Added by Beat Richartz over 1 year ago. Updated over 1 year ago.

[ruby-core:51210]
Status:Rejected
Priority:Normal
Assignee:Shugo Maeda
Category:-
Target version:-
ruby -v:ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-darwin12.2.1] Backport:

Description

=begin
When (({define_method})) is used within the refine block argument, calls to super will result in a stack level too deep. Definitions with def can call super without problems.

module A
refine Fixnum do
%i(+ -).each do |m|
define_method m do |other|
super(other)
end
end

  def * other
    super(other)
  end
end

end

class B
using A

def working
  puts 'working'
  1 * 1
end

def error
  puts 'stack level too deep'
  1 + 1
end

end

puts B.new.working
puts B.new.error

=end

bug.rb Magnifier (359 Bytes) Beat Richartz, 01/01/2013 02:49 AM

History

#1 Updated by Shugo Maeda over 1 year ago

  • Status changed from Open to Feedback
  • Assignee set to Shugo Maeda

Hi,

beatrichartz (Beat Richartz) wrote:

When define_method is used within the refine block argument, calls to super will result in a stack level too deep. Definitions with def can call super without problems.

r38126 is too old. Please try the latest revision, where Module#using is removed.

The following modified program doesn't cause a stack level too deep error in my Ubuntu box (ruby 2.0.0dev (2012-12-29 trunk 38655) [i686-linux]):

require 'refinement'
module A
refine Fixnum do
%i(+ -).each do |m|
define_method m do |other|
super(other)
end
end

  def * other
    super(other)
  end
end

end

using A

class B
def working
puts 'working'
1 * 1
end

def error
  puts 'stack level too deep'
  1 + 1
end

end

puts B.new.working
puts B.new.error

#2 Updated by Nobuyoshi Nakada over 1 year ago

  • Description updated (diff)

#3 Updated by Beat Richartz over 1 year ago

Ok, also working for me here with r38676. Should have checked the new versions before, sorry. Have a nice day!

#4 Updated by Shugo Maeda over 1 year ago

  • Status changed from Feedback to Rejected

beatrichartz (Beat Richartz) wrote:

Ok, also working for me here with r38676. Should have checked the new versions before, sorry. Have a nice day!

Thanks for your confirmation. So I close this issue.

Also available in: Atom PDF