Project

General

Profile

Actions

Bug #11283

closed

Block assigned implicitly

Added by nepalez (Andrew Kozin) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
1.9.3, 2.0, 2.1, 2.2, ruby-head
[ruby-core:69655]

Description

That is how it works:

module Test
  def self.build(&block)
    klass = Class.new(Object)
    klass.__send__(:define_method, :foo)
    klass.__send__(:define_method, :bar)
    klass
  end
end

Tested = Test.build { :foo }
# warning: tried to create Proc object without a block
# => Tested
Tested.new.foo
# => :foo
Tested.new.bar
# => :foo

The block is assigned to all calls to :define_method via Object#__send__ implicitly, while it wasn't asked to.

The behaviour is tested under MRI 1.9.3, 2.0, 2.1, 2.2, ruby-head. It doesn't occur under rbx-2 and jruby (1.7, 9.0.0.0).

For the context look at this thread https://github.com/mbj/mutant/issues/356

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0