Project

General

Profile

Bug #9141

define_singleton_method creates private method

Added by Soilent (Konstantin _) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.0dev (2013-09-22 trunk 43011) [x86_64-darwin12.5.0]
[ruby-core:58497]

Description

Hello,
I stumbled upon the following problem:

irb(main):001:0> guy = "Bob"
=> "Bob"
irb(main):002:0> guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
=> :hello
irb(main):003:0> guy.hello
NoMethodError: private method `hello' called for "Bob":String
from (irb):3


Related issues

Related to Backport21 - Backport #9296: please backport r44380 (visibility of methods defined by define_method)Closed2013-12-25
Is duplicate of Ruby trunk - Bug #9005: object.send(:define_method, ...){...} creates private methodClosed2013-10-09

Associated revisions

Revision 44380
Added by nobu (Nobuyoshi Nakada) over 3 years ago

proc.c: make method by define_method public

  • proc.c (rb_mod_define_method): consider visibility only if self in the caller is same as the receiver, otherwise make public as well as old behavior. [Bug #9005] [Bug #9141]
  • vm.c (rb_vm_cref_in_context): return ruby level cref if self is same.

Revision 44380
Added by nobu (Nobuyoshi Nakada) over 3 years ago

proc.c: make method by define_method public

  • proc.c (rb_mod_define_method): consider visibility only if self in the caller is same as the receiver, otherwise make public as well as old behavior. [Bug #9005] [Bug #9141]
  • vm.c (rb_vm_cref_in_context): return ruby level cref if self is same.

Revision 44380
Added by nobu (Nobuyoshi Nakada) over 3 years ago

proc.c: make method by define_method public

  • proc.c (rb_mod_define_method): consider visibility only if self in the caller is same as the receiver, otherwise make public as well as old behavior. [Bug #9005] [Bug #9141]
  • vm.c (rb_vm_cref_in_context): return ruby level cref if self is same.

Revision 44380
Added by nobu (Nobuyoshi Nakada) over 3 years ago

proc.c: make method by define_method public

  • proc.c (rb_mod_define_method): consider visibility only if self in the caller is same as the receiver, otherwise make public as well as old behavior. [Bug #9005] [Bug #9141]
  • vm.c (rb_vm_cref_in_context): return ruby level cref if self is same.

History

#1 [ruby-core:58503] Updated by jeremyevans0 (Jeremy Evans) over 3 years ago

This is probably related to #9005.

#2 Updated by nobu (Nobuyoshi Nakada) over 3 years ago

  • Status changed from Open to Closed

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


proc.c: make method by define_method public

  • proc.c (rb_mod_define_method): consider visibility only if self in the caller is same as the receiver, otherwise make public as well as old behavior. [Bug #9005] [Bug #9141]
  • vm.c (rb_vm_cref_in_context): return ruby level cref if self is same.

#3 [ruby-core:59294] Updated by nobu (Nobuyoshi Nakada) over 3 years ago

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

Also available in: Atom PDF