From: "ko1 (Koichi Sasada)" Date: 2012-07-14T16:17:08+09:00 Subject: [ruby-core:46431] [ruby-trunk - Bug #6039][Rejected] lambda vs proc; #to_ary w/ splat bug Issue #6039 has been updated by ko1 (Koichi Sasada). Status changed from Assigned to Rejected This behavior is intended. ---------------------------------------- Bug #6039: lambda vs proc; #to_ary w/ splat bug https://bugs.ruby-lang.org/issues/6039#change-28051 Author: ddebernardy (Denis de Bernardy) Status: Rejected Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: ruby -v: 1.9.3 to_ary apparently gets called in edge cases when a proc has a splat argument: good = Class.new do def to_ary [:bad] end end.new foo = lambda { |*bar| bar.first } foo.call(good) foo = lambda { |bar, *baz| bar } foo.call(good) foo = proc { |*bar| bar.first } foo.call(good) foo = proc { |bar, *baz| bar } foo.call(good) >> RUBY_VERSION => "1.9.3" >> good = Class.new do ?> def to_ary >> [:bad] >> end >> end.new => #<#:0x00000100a399d0> >> ?> foo = lambda { |*bar| bar.first } => # >> foo.call(good) => #<#:0x00000100a399d0> >> ?> foo = lambda { |bar, *baz| bar } => # >> foo.call(good) => #<#:0x00000100a399d0> >> ?> foo = proc { |*bar| bar.first } => # >> foo.call(good) => #<#:0x00000100a399d0> >> ?> foo = proc { |bar, *baz| bar } => # >> foo.call(good) => :bad -- http://bugs.ruby-lang.org/