Issue #7993 has been reported by no6v (Nobuhiro IMAI). ---------------------------------------- Bug #7993: owner of methods defined after using Module#prepend https://bugs.ruby-lang.org/issues/7993 Author: no6v (Nobuhiro IMAI) Status: Open Priority: Normal Assignee: Category: core Target version: ruby -v: RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-03-01 trunk 39546) [x86_64-linux]" =begin The owner of methods defined after using Module#prepend seems to be incorrect. RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-03-01 trunk 39546) [x86_64-linux]" class C attr_reader :a prepend Module.new attr_reader :b end C.instance_method(:a).owner # => C C.instance_method(:b).owner # => #<C:0x00000000a52300> C.new.method(:a).owner # => C C.new.method(:b).owner # => #<C:0x00000000a52300> module M attr_reader :a prepend Module.new attr_reader :b end M.instance_method(:a).owner # => M M.instance_method(:b).owner # => # ~> -:19:in `<main>': undefined method `class' for #<M:0x00000000a515b8> (NoMethodError) =end
on 2013-03-01 16:02
on 2013-03-01 18:42
Issue #7993 has been updated by marcandre (Marc-Andre Lafortune). Agreed. I described this in [ruby-core:52261], part of issue #7842. ---------------------------------------- Bug #7993: owner of methods defined after using Module#prepend https://bugs.ruby-lang.org/issues/7993#change-37232 Author: no6v (Nobuhiro IMAI) Status: Open Priority: Normal Assignee: Category: core Target version: ruby -v: RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-03-01 trunk 39546) [x86_64-linux]" =begin The owner of methods defined after using Module#prepend seems to be incorrect. RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-03-01 trunk 39546) [x86_64-linux]" class C attr_reader :a prepend Module.new attr_reader :b end C.instance_method(:a).owner # => C C.instance_method(:b).owner # => #<C:0x00000000a52300> C.new.method(:a).owner # => C C.new.method(:b).owner # => #<C:0x00000000a52300> module M attr_reader :a prepend Module.new attr_reader :b end M.instance_method(:a).owner # => M M.instance_method(:b).owner # => # ~> -:19:in `<main>': undefined method `class' for #<M:0x00000000a515b8> (NoMethodError) =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
Log in with Google account | Log in with Yahoo account
No account? Register here.