Forum: Ruby-core [ruby-trunk - Bug #7643][Open] call to super in define_method in refine results in stack level too d

Posted by beatrichartz (Beat Richartz) (Guest)
on 2012-12-31 18:49
(Received via mailing list)
Issue #7643 has been reported by beatrichartz (Beat Richartz).

----------------------------------------
Bug #7643: call to super in define_method in refine results in stack 
level too deep
https://bugs.ruby-lang.org/issues/7643

Author: beatrichartz (Beat Richartz)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-darwin12.2.1]


=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
Posted by shugo (Shugo Maeda) (Guest)
on 2013-01-02 02:31
(Received via mailing list)
Issue #7643 has been updated by shugo (Shugo Maeda).

Status changed from Open to Feedback
Assignee set to shugo (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

----------------------------------------
Bug #7643: call to super in define_method in refine results in stack 
level too deep
https://bugs.ruby-lang.org/issues/7643#change-35176

Author: beatrichartz (Beat Richartz)
Status: Feedback
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category:
Target version:
ruby -v: ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-darwin12.2.1]


=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
Posted by Nobuyoshi Nakada (nobu)
on 2013-01-02 02:54
(Received via mailing list)
Issue #7643 has been updated by nobu (Nobuyoshi Nakada).

Description updated


----------------------------------------
Bug #7643: call to super in define_method in refine results in stack 
level too deep
https://bugs.ruby-lang.org/issues/7643#change-35177

Author: beatrichartz (Beat Richartz)
Status: Feedback
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category:
Target version:
ruby -v: ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-darwin12.2.1]


=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
Posted by beatrichartz (Beat Richartz) (Guest)
on 2013-01-02 13:48
(Received via mailing list)
Issue #7643 has been updated by beatrichartz (Beat Richartz).


Ok, also working for me here with r38676. Should have checked the new 
versions before, sorry. Have a nice day!
----------------------------------------
Bug #7643: call to super in define_method in refine results in stack 
level too deep
https://bugs.ruby-lang.org/issues/7643#change-35180

Author: beatrichartz (Beat Richartz)
Status: Feedback
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category:
Target version:
ruby -v: ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-darwin12.2.1]


=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
Posted by shugo (Shugo Maeda) (Guest)
on 2013-01-07 04:09
(Received via mailing list)
Issue #7643 has been updated by shugo (Shugo Maeda).

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.

----------------------------------------
Bug #7643: call to super in define_method in refine results in stack 
level too deep
https://bugs.ruby-lang.org/issues/7643#change-35243

Author: beatrichartz (Beat Richartz)
Status: Rejected
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category:
Target version:
ruby -v: ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-darwin12.2.1]


=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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.