From: "Mikael Høilund" Date: 2008-05-29T11:43:51+09:00 Subject: Bug in Method#to_proc on method with block I seem to have found a bug in Ruby 1.9. Method#to_proc doesn't seem to preserve receptance of blocks. This script demonstrates it: --8<---- class ProcTester def one_and_block(arg, &block) puts "one_and_block got arg #{arg} and block: #{block.inspect}." puts "Something is wrong." if block.nil? end end pt = ProcTester.new dummy = proc { :dummy } puts "Direct call:" pt.one_and_block(:hi, &dummy) puts puts "Get Method, call" meth = pt.method(:one_and_block) p meth meth.call(:hi, &dummy) puts puts "Convert Method to Proc, call" proc_obj = meth.to_proc proc_obj.call(:hi, &dummy) # This fails --8<---- The output is: --8<---- Direct call: one_and_block got arg hi and block: #. Get Method, call # one_and_block got arg hi and block: #. Convert Method to Proc, call one_and_block got arg hi and block: nil. Something is wrong. --8<---- One would expect the Proc object to have the same parameters, as it is possible to define a block parameter in Procs in 1.9: proc do |&block| block.call end.call(&dummy) # => :dummy I asked in #ruby-lang on irc.freenode.net, and it doesn't seem to be a known bug. -- Mikael H�ilund http://hoilund.org/