Bug #7621
closedブロック引数にデフォルト値を指定したときに配列を渡した際の挙動が1.9.3と変わっている
Description
=begin
ブロックをとるメソッドや Proc.new で、ブロック引数にデフォルト値を指定したときに配列を渡した際の
挙動が 1.9.3 と変わっています。
proc のとき¶
$ ruby -v -e 'proc {|ary = []| p ary }.([1, 2, 3])'
ruby 2.0.0dev (2012-12-25) [x86_64-darwin12.2.1]
1
$ ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]
[1, 2, 3]
block のとき¶
$cat yield_ary.rb
def yield_ary
yield([1, 2, 3])
end
yield_ary {|ary = []| p ary }
$ ruby -v yield_ary.rb
ruby 2.0.0dev (2012-12-25) [x86_64-darwin12.2.1]
1
$ ruby -v yield_ary.rb
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]
[1, 2, 3]
lambda のときの挙動は 1.9.3 と同じようです。
$ ruby -v -e 'lambda {|ary = []| p ary }.([1, 2, 3])'
ruby 2.0.0dev (2012-12-25) [x86_64-darwin12.2.1]
[1, 2, 3]
$ ruby -v -e 'lambda {|ary = []| p ary }.([1, 2, 3])'
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]
[1, 2, 3]
=end
Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r38639.
三村, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
vm_insnhelper.c: no splat single opt arg
- vm_insnhelper.c (vm_yield_setup_block_args): pass single argument to
single optional parameter unchanged without splatting. [Bug #7621]
[ruby-dev:46801]