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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-12-28 02:50:57 +00:00
Родитель d5a39c0aa8
Коммит 0ea1e43174
3 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Fri Dec 28 11:50:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_yield_setup_block_args): pass single argument to
single optional parameter unchanged without splatting. [Bug #7621]
[ruby-dev:46801]
Fri Dec 28 11:17:47 2012 Shugo Maeda <shugo@ruby-lang.org>
* proc.c (method_eq): fix the documentation to refer to owner.

Просмотреть файл

@ -499,6 +499,22 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3], pr.call([1,2,3,4,5,6])
end
def test_proc_args_opt_signle
bug7621 = '[ruby-dev:46801]'
pr = proc {|a=:a|
a
}
assert_equal :a, pr.call()
assert_equal 1, pr.call(1)
assert_equal 1, pr.call(1,2)
assert_equal [], pr.call([]), bug7621
assert_equal [1], pr.call([1]), bug7621
assert_equal [1, 2], pr.call([1,2]), bug7621
assert_equal [1, 2, 3], pr.call([1,2,3]), bug7621
assert_equal [1, 2, 3, 4], pr.call([1,2,3,4]), bug7621
end
def test_proc_args_pos_opt_post
pr = proc {|a,b,c=:c,d,e|
[a,b,c,d,e]

Просмотреть файл

@ -2092,7 +2092,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq,
*/
arg0 = argv[0];
if (!(iseq->arg_simple & 0x02) && /* exclude {|a|} */
(m + iseq->arg_opts + iseq->arg_post_len) > 0 && /* this process is meaningful */
((m + iseq->arg_post_len) > 0 || iseq->arg_opts > 2) && /* this process is meaningful */
argc == 1 && !NIL_P(ary = rb_check_array_type(arg0))) { /* rhs is only an array */
th->mark_stack_len = argc = RARRAY_LENINT(ary);