Project

General

Profile

Backport #8686

Calling define_singleton_method on an "extended self" module raises TypeError: compared with non class/module

Added by krieghan (Krieghan Riley) almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:56174]

Description

The following code, issued through rake console, works fine on ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0],
but fails on ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin11.4.2].

module A
extend self

def a
return "a"
end
end

def b
return "b"
end

a = A.method(:a)
A.define_singleton_method(:a, method(:b))
A.define_singleton_method(:a, a)

On ruby 2.0, the last line raises the following exception:

TypeError: compared with non class/module
from (irb):15:in define_singleton_method'
from (irb):15
from ./Rakefile:17:in
block in '
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in call'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in
block in execute'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in each'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in
execute'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:175:in block in invoke_with_call_chain'
from ~/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in
mon_synchronize'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in invoke_with_call_chain'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:161:in
invoke'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:149:in invoke_task'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in
block (2 levels) in top_level'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in each'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in
block in top_level'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:115:in run_with_threads'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:100:in
top_level'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:78:in block in run'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in
standard_exception_handling'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in run'
from ./vendor/bundler/ruby/2.0.0/gems/rake-10.1.0/bin/rake:33:in
'
from ./vendor/bundler/ruby/2.0.0/bin/rake:23:in load'
from ./vendor/bundler/ruby/2.0.0/bin/rake:23:in
'2.0.0 :016 >

The result that I expect is that the original method "a" should be replaced back on the module (and in 1.9.3, that is exactly what happens).

Associated revisions

Revision 5e98991f
Added by charliesome (Charlie Somerville) almost 6 years ago

  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 42380
Added by charliesome (Charlie Somerville) almost 6 years ago

  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

Revision 42380
Added by charliesome (Charlie Somerville) almost 6 years ago

  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

Revision 42380
Added by charliesome (Charlie Somerville) almost 6 years ago

  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

Revision 42380
Added by charliesome (Charlie Somerville) almost 6 years ago

  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

Revision 42380
Added by charliesome (Charlie Somerville) almost 6 years ago

  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

Revision 42380
Added by charliesome (Charlie Somerville) almost 6 years ago

  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

Revision 8ab9a657
Added by nagachika (Tomoyuki Chikanaga) over 5 years ago

merge revision(s) 40021,42380: [Backport #8686]

    test_method.rb: split

    * test/ruby/test_method.rb (test_define_method): split for each tests.
    * object.c (rb_class_inherited_p): allow iclasses to be tested for
      inheritance. [Bug #8686] [ruby-core:56174]

    * test/ruby/test_method.rb: add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@42914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 42914
Added by nagachika (Tomoyuki Chikanaga) over 5 years ago

merge revision(s) 40021,42380: [Backport #8686]

test_method.rb: split

* test/ruby/test_method.rb (test_define_method): split for each tests.
* object.c (rb_class_inherited_p): allow iclasses to be tested for
  inheritance. [Bug #8686] [ruby-core:56174]

* test/ruby/test_method.rb: add test

History

Updated by nagachika (Tomoyuki Chikanaga) almost 6 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED
#2

Updated by charliesome (Charlie Somerville) almost 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r42380.
Krieghan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • object.c (rb_class_inherited_p): allow iclasses to be tested for
    inheritance. [Bug #8686] [ruby-core:56174]

  • test/ruby/test_method.rb: add test

#3

Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Status changed from Closed to Assigned
  • Assignee set to nagachika (Tomoyuki Chikanaga)
#4

Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r42914.
Krieghan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40021,42380: [Backport #8686]

test_method.rb: split

* test/ruby/test_method.rb (test_define_method): split for each tests.
* object.c (rb_class_inherited_p): allow iclasses to be tested for
  inheritance. [Bug #8686] [ruby-core:56174]

* test/ruby/test_method.rb: add test

Also available in: Atom PDF