Project

General

Profile

Actions

Bug #9005

closed

object.send(:define_method, ...){...} creates private method

Added by jeremyevans0 (Jeremy Evans) about 11 years ago. Updated about 10 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.1.0dev (2013-09-22 trunk 43011) [i386-openbsd]
[ruby-core:57747]

Description

I assume this is caused by r40022, which made define_method consider visibility. However, visibility should only be considered if define_method is called normally, not via send. When called via send, it should define a public method. Here's example code showing the error:

$ ruby21 -ve "Object.send(:define_method, :foo){|*a| 1}.foo"
-e:1:in <main>': private method foo' called for :foo:Symbol (NoMethodError)

I apologize in advance if this has already been fixed (I tested 2.1.0-preview1, not trunk), but from the commit logs it doesn't appear to have been.


Related issues 2 (0 open2 closed)

Related to Backport21 - Backport #9296: please backport r44380 (visibility of methods defined by define_method)Closednaruse (Yui NARUSE)12/25/2013Actions
Has duplicate Ruby master - Bug #9141: define_singleton_method creates private methodClosed11/22/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0