Project

General

Profile

Actions

Bug #7621

closed

ブロック引数にデフォルト値を指定したときに配列を渡した際の挙動が1.9.3と変わっている

Added by takkanm (三村 益隆) almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.0.0dev
Backport:
[ruby-dev:46801]

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


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #5730: Optinal block parameters assigns wrongClosed12/09/2011Actions
Actions #1

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]
Actions

Also available in: Atom PDF

Like0
Like0