Issue #5807 has been reported by Silvio Cordeiro.

----------------------------------------
Backport #5807: "define_method" not consistent with "def"
https://bugs.ruby-lang.org/issues/5807

Author: Silvio Cordeiro
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


=begin
Under at least Ruby 1.8.7 and 1.9.1, the following definitions are not equivalent:

(({
def foo1
  puts "foo1 called"
end

class << self
  define_method(:foo2) do
    puts "foo2 called"
  end
end
}))

While ((|foo1|)) always works, ((|foo2|)) is considered *undefined* in some contexts. For example, this method works:

(({
def call_foos
  foo1
  foo2
end
}))

but ((|Bad.new|)) below would not work, failing because ((|foo2|)) is undefined:

(({
class Bad
  def initialize
    foo1
    foo2
  end
end
}))

See attached file with an example code that is even stranger than this.
=end


-- 
http://redmine.ruby-lang.org