1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_insnhelper.c (vm_yield_setup_block_args): splat single

argument if optinal arguments are defined not only mandatory or
  post arguments.  [ruby-core:41557] [Bug #5730]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-12-12 20:50:09 +00:00
parent 900b4a6db6
commit 50ae8a8651
3 changed files with 280 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Tue Dec 13 05:50:07 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_yield_setup_block_args): splat single
argument if optinal arguments are defined not only mandatory or
post arguments. [ruby-core:41557] [Bug #5730]
Mon Dec 12 22:35:39 2011 Shugo Maeda <shugo@ruby-lang.org>
* parse.y (stmt_or_begin): changed the error message for BEGIN not

View file

@ -405,6 +405,29 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, [3, 4, 5], 6,7], pr.call([1,2,3,4,5,6,7])
end
def test_proc_args_rest_post
pr = proc {|*a,b,c|
[a,b,c]
}
assert_equal [[], nil, nil], pr.call()
assert_equal [[], 1, nil], pr.call(1)
assert_equal [[], 1, 2], pr.call(1,2)
assert_equal [[1], 2, 3], pr.call(1,2,3)
assert_equal [[1, 2], 3, 4], pr.call(1,2,3,4)
assert_equal [[1, 2, 3], 4, 5], pr.call(1,2,3,4,5)
assert_equal [[1, 2, 3, 4], 5, 6], pr.call(1,2,3,4,5,6)
assert_equal [[1, 2, 3, 4, 5], 6,7], pr.call(1,2,3,4,5,6,7)
assert_equal [[], nil, nil], pr.call([])
assert_equal [[], 1, nil], pr.call([1])
assert_equal [[], 1, 2], pr.call([1,2])
assert_equal [[1], 2, 3], pr.call([1,2,3])
assert_equal [[1, 2], 3, 4], pr.call([1,2,3,4])
assert_equal [[1, 2, 3], 4, 5], pr.call([1,2,3,4,5])
assert_equal [[1, 2, 3, 4], 5, 6], pr.call([1,2,3,4,5,6])
assert_equal [[1, 2, 3, 4, 5], 6,7], pr.call([1,2,3,4,5,6,7])
end
def test_proc_args_pos_opt
pr = proc {|a,b,c=:c|
[a,b,c]
@ -426,6 +449,27 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3], pr.call([1,2,3,4,5,6])
end
def test_proc_args_opt
pr = proc {|a=:a,b=:b,c=:c|
[a,b,c]
}
assert_equal [:a, :b, :c], pr.call()
assert_equal [1, :b, :c], pr.call(1)
assert_equal [1, 2, :c], pr.call(1,2)
assert_equal [1, 2, 3], pr.call(1,2,3)
assert_equal [1, 2, 3], pr.call(1,2,3,4)
assert_equal [1, 2, 3], pr.call(1,2,3,4,5)
assert_equal [1, 2, 3], pr.call(1,2,3,4,5,6)
assert_equal [:a, :b, :c], pr.call([])
assert_equal [1, :b, :c], pr.call([1])
assert_equal [1, 2, :c], pr.call([1,2])
assert_equal [1, 2, 3], pr.call([1,2,3])
assert_equal [1, 2, 3], pr.call([1,2,3,4])
assert_equal [1, 2, 3], pr.call([1,2,3,4,5])
assert_equal [1, 2, 3], pr.call([1,2,3,4,5,6])
end
def test_proc_args_pos_opt_post
pr = proc {|a,b,c=:c,d,e|
[a,b,c,d,e]
@ -447,6 +491,27 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3, 4, 5], pr.call([1,2,3,4,5,6])
end
def test_proc_args_opt_post
pr = proc {|a=:a,b=:b,c=:c,d,e|
[a,b,c,d,e]
}
assert_equal [:a, :b, :c, nil, nil], pr.call()
assert_equal [:a, :b, :c, 1, nil], pr.call(1)
assert_equal [:a, :b, :c, 1, 2], pr.call(1,2)
assert_equal [1, :b, :c, 2, 3], pr.call(1,2,3)
assert_equal [1, 2, :c, 3, 4], pr.call(1,2,3,4)
assert_equal [1, 2, 3, 4, 5], pr.call(1,2,3,4,5)
assert_equal [1, 2, 3, 4, 5], pr.call(1,2,3,4,5,6)
assert_equal [:a, :b, :c, nil, nil], pr.call([])
assert_equal [:a, :b, :c, 1, nil], pr.call([1])
assert_equal [:a, :b, :c, 1, 2], pr.call([1,2])
assert_equal [1, :b, :c, 2, 3], pr.call([1,2,3])
assert_equal [1, 2, :c, 3, 4], pr.call([1,2,3,4])
assert_equal [1, 2, 3, 4, 5], pr.call([1,2,3,4,5])
assert_equal [1, 2, 3, 4, 5], pr.call([1,2,3,4,5,6])
end
def test_proc_args_pos_opt_rest
pr = proc {|a,b,c=:c,*d|
[a,b,c,d]
@ -466,6 +531,25 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3, [4, 5]], pr.call([1,2,3,4,5])
end
def test_proc_args_opt_rest
pr = proc {|a=:a,b=:b,c=:c,*d|
[a,b,c,d]
}
assert_equal [:a, :b, :c, []], pr.call()
assert_equal [1, :b, :c, []], pr.call(1)
assert_equal [1, 2, :c, []], pr.call(1,2)
assert_equal [1, 2, 3, []], pr.call(1,2,3)
assert_equal [1, 2, 3, [4]], pr.call(1,2,3,4)
assert_equal [1, 2, 3, [4, 5]], pr.call(1,2,3,4,5)
assert_equal [:a, :b, :c, []], pr.call([])
assert_equal [1, :b, :c, []], pr.call([1])
assert_equal [1, 2, :c, []], pr.call([1,2])
assert_equal [1, 2, 3, []], pr.call([1,2,3])
assert_equal [1, 2, 3, [4]], pr.call([1,2,3,4])
assert_equal [1, 2, 3, [4, 5]], pr.call([1,2,3,4,5])
end
def test_proc_args_pos_opt_rest_post
pr = proc {|a,b,c=:c,*d,e|
[a,b,c,d,e]
@ -487,6 +571,27 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3, [4,5], 6], pr.call([1,2,3,4,5,6])
end
def test_proc_args_opt_rest_post
pr = proc {|a=:a,b=:b,c=:c,*d,e|
[a,b,c,d,e]
}
assert_equal [:a, :b, :c, [], nil], pr.call()
assert_equal [:a, :b, :c, [], 1], pr.call(1)
assert_equal [1, :b, :c, [], 2], pr.call(1,2)
assert_equal [1, 2, :c, [], 3], pr.call(1,2,3)
assert_equal [1, 2, 3, [], 4], pr.call(1,2,3,4)
assert_equal [1, 2, 3, [4], 5], pr.call(1,2,3,4,5)
assert_equal [1, 2, 3, [4,5], 6], pr.call(1,2,3,4,5,6)
assert_equal [:a, :b, :c, [], nil], pr.call([])
assert_equal [:a, :b, :c, [], 1], pr.call([1])
assert_equal [1, :b, :c, [], 2], pr.call([1,2])
assert_equal [1, 2, :c, [], 3], pr.call([1,2,3])
assert_equal [1, 2, 3, [], 4], pr.call([1,2,3,4])
assert_equal [1, 2, 3, [4], 5], pr.call([1,2,3,4,5])
assert_equal [1, 2, 3, [4,5], 6], pr.call([1,2,3,4,5,6])
end
def test_proc_args_pos_block
pr = proc {|a,b,&c|
[a, b, c.class, c&&c.call(:x)]
@ -497,6 +602,12 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, NilClass, nil], pr.call(1,2,3)
assert_equal [1, 2, NilClass, nil], pr.call(1,2,3,4)
assert_equal [nil, nil, NilClass, nil], pr.call([])
assert_equal [1, nil, NilClass, nil], pr.call([1])
assert_equal [1, 2, NilClass, nil], pr.call([1,2])
assert_equal [1, 2, NilClass, nil], pr.call([1,2,3])
assert_equal [1, 2, NilClass, nil], pr.call([1,2,3,4])
assert_equal [nil, nil, Proc, :proc], (pr.call(){ :proc })
assert_equal [1, nil, Proc, :proc], (pr.call(1){ :proc })
assert_equal [1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
@ -533,6 +644,23 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, [3,4], Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
end
def test_proc_args_rest_block
pr = proc {|*c,&d|
[c, d.class, d&&d.call(:x)]
}
assert_equal [[], NilClass, nil], pr.call()
assert_equal [[1], NilClass, nil], pr.call(1)
assert_equal [[1, 2], NilClass, nil], pr.call(1,2)
assert_equal [[], Proc, :proc], (pr.call(){ :proc })
assert_equal [[1], Proc, :proc], (pr.call(1){ :proc })
assert_equal [[1, 2], Proc, :proc], (pr.call(1, 2){ :proc })
assert_equal [[], Proc, :x], (pr.call(){|x| x})
assert_equal [[1], Proc, :x], (pr.call(1){|x| x})
assert_equal [[1, 2], Proc, :x], (pr.call(1, 2){|x| x})
end
def test_proc_args_pos_rest_post_block
pr = proc {|a,b,*c,d,e,&f|
[a, b, c, d, e, f.class, f&&f.call(:x)]
@ -562,6 +690,29 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, [3,4], 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
end
def test_proc_args_rest_post_block
pr = proc {|*c,d,e,&f|
[c, d, e, f.class, f&&f.call(:x)]
}
assert_equal [[], nil, nil, NilClass, nil], pr.call()
assert_equal [[], 1, nil, NilClass, nil], pr.call(1)
assert_equal [[], 1, 2, NilClass, nil], pr.call(1,2)
assert_equal [[1], 2, 3, NilClass, nil], pr.call(1,2,3)
assert_equal [[1, 2], 3, 4, NilClass, nil], pr.call(1,2,3,4)
assert_equal [[], nil, nil, Proc, :proc], (pr.call(){ :proc })
assert_equal [[], 1, nil, Proc, :proc], (pr.call(1){ :proc })
assert_equal [[], 1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
assert_equal [[1], 2, 3, Proc, :proc], (pr.call(1, 2, 3){ :proc })
assert_equal [[1, 2], 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
assert_equal [[], nil, nil, Proc, :x], (pr.call(){|x| x})
assert_equal [[], 1, nil, Proc, :x], (pr.call(1){|x| x})
assert_equal [[], 1, 2, Proc, :x], (pr.call(1, 2){|x| x})
assert_equal [[1], 2, 3, Proc, :x], (pr.call(1, 2, 3){|x| x})
assert_equal [[1, 2], 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
end
def test_proc_args_pos_opt_block
pr = proc {|a,b,c=:c,d=:d,&e|
[a, b, c, d, e.class, e&&e.call(:x)]
@ -588,6 +739,32 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
end
def test_proc_args_opt_block
pr = proc {|a=:a,b=:b,c=:c,d=:d,&e|
[a, b, c, d, e.class, e&&e.call(:x)]
}
assert_equal [:a, :b, :c, :d, NilClass, nil], pr.call()
assert_equal [1, :b, :c, :d, NilClass, nil], pr.call(1)
assert_equal [1, 2, :c, :d, NilClass, nil], pr.call(1,2)
assert_equal [1, 2, 3, :d, NilClass, nil], pr.call(1,2,3)
assert_equal [1, 2, 3, 4, NilClass, nil], pr.call(1,2,3,4)
assert_equal [1, 2, 3, 4, NilClass, nil], pr.call(1,2,3,4,5)
assert_equal [:a, :b, :c, :d, Proc, :proc], (pr.call(){ :proc })
assert_equal [1, :b, :c, :d, Proc, :proc], (pr.call(1){ :proc })
assert_equal [1, 2, :c, :d, Proc, :proc], (pr.call(1, 2){ :proc })
assert_equal [1, 2, 3, :d, Proc, :proc], (pr.call(1, 2, 3){ :proc })
assert_equal [1, 2, 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
assert_equal [1, 2, 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
assert_equal [:a, :b, :c, :d, Proc, :x], (pr.call(){|x| x})
assert_equal [1, :b, :c, :d, Proc, :x], (pr.call(1){|x| x})
assert_equal [1, 2, :c, :d, Proc, :x], (pr.call(1, 2){|x| x})
assert_equal [1, 2, 3, :d, Proc, :x], (pr.call(1, 2, 3){|x| x})
assert_equal [1, 2, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
assert_equal [1, 2, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
end
def test_proc_args_pos_opt_post_block
pr = proc {|a,b,c=:c,d=:d,e,f,&g|
[a, b, c, d, e, f, g.class, g&&g.call(:x)]
@ -620,6 +797,38 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3, 4, 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7){|x| x})
end
def test_proc_args_opt_post_block
pr = proc {|a=:a,b=:b,c=:c,d=:d,e,f,&g|
[a, b, c, d, e, f, g.class, g&&g.call(:x)]
}
assert_equal [:a, :b, :c, :d, nil, nil, NilClass, nil], pr.call()
assert_equal [:a, :b, :c, :d, 1, nil, NilClass, nil], pr.call(1)
assert_equal [:a, :b, :c, :d, 1, 2, NilClass, nil], pr.call(1,2)
assert_equal [1, :b, :c, :d, 2, 3, NilClass, nil], pr.call(1,2,3)
assert_equal [1, 2, :c, :d, 3, 4, NilClass, nil], pr.call(1,2,3,4)
assert_equal [1, 2, 3, :d, 4, 5, NilClass, nil], pr.call(1,2,3,4,5)
assert_equal [1, 2, 3, 4, 5, 6, NilClass, nil], pr.call(1,2,3,4,5,6)
assert_equal [1, 2, 3, 4, 5, 6, NilClass, nil], pr.call(1,2,3,4,5,6,7)
assert_equal [:a, :b, :c, :d, nil, nil, Proc, :proc], (pr.call(){ :proc })
assert_equal [:a, :b, :c, :d, 1, nil, Proc, :proc], (pr.call(1){ :proc })
assert_equal [:a, :b, :c, :d, 1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
assert_equal [1, :b, :c, :d, 2, 3, Proc, :proc], (pr.call(1, 2, 3){ :proc })
assert_equal [1, 2, :c, :d, 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
assert_equal [1, 2, 3, :d, 4, 5, Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
assert_equal [1, 2, 3, 4, 5, 6, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6){ :proc })
assert_equal [1, 2, 3, 4, 5, 6, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6, 7){ :proc })
assert_equal [:a, :b, :c, :d, nil, nil, Proc, :x], (pr.call(){|x| x})
assert_equal [:a, :b, :c, :d, 1, nil, Proc, :x], (pr.call(1){|x| x})
assert_equal [:a, :b, :c, :d, 1, 2, Proc, :x], (pr.call(1, 2){|x| x})
assert_equal [1, :b, :c, :d, 2, 3, Proc, :x], (pr.call(1, 2, 3){|x| x})
assert_equal [1, 2, :c, :d, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
assert_equal [1, 2, 3, :d, 4, 5, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
assert_equal [1, 2, 3, 4, 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
assert_equal [1, 2, 3, 4, 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7){|x| x})
end
def test_proc_args_pos_opt_rest_block
pr = proc {|a,b,c=:c,d=:d,*e,&f|
[a, b, c, d, e, f.class, f&&f.call(:x)]
@ -649,6 +858,35 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3, 4, [5,6], Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
end
def test_proc_args_opt_rest_block
pr = proc {|a=:a,b=:b,c=:c,d=:d,*e,&f|
[a, b, c, d, e, f.class, f&&f.call(:x)]
}
assert_equal [:a, :b, :c, :d, [], NilClass, nil], pr.call()
assert_equal [1, :b, :c, :d, [], NilClass, nil], pr.call(1)
assert_equal [1, 2, :c, :d, [], NilClass, nil], pr.call(1,2)
assert_equal [1, 2, 3, :d, [], NilClass, nil], pr.call(1,2,3)
assert_equal [1, 2, 3, 4, [], NilClass, nil], pr.call(1,2,3,4)
assert_equal [1, 2, 3, 4, [5], NilClass, nil], pr.call(1,2,3,4,5)
assert_equal [1, 2, 3, 4, [5,6], NilClass, nil], pr.call(1,2,3,4,5,6)
assert_equal [:a, :b, :c, :d, [], Proc, :proc], (pr.call(){ :proc })
assert_equal [1, :b, :c, :d, [], Proc, :proc], (pr.call(1){ :proc })
assert_equal [1, 2, :c, :d, [], Proc, :proc], (pr.call(1, 2){ :proc })
assert_equal [1, 2, 3, :d, [], Proc, :proc], (pr.call(1, 2, 3){ :proc })
assert_equal [1, 2, 3, 4, [], Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
assert_equal [1, 2, 3, 4, [5], Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
assert_equal [1, 2, 3, 4, [5,6], Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6){ :proc })
assert_equal [:a, :b, :c, :d, [], Proc, :x], (pr.call(){|x| x})
assert_equal [1, :b, :c, :d, [], Proc, :x], (pr.call(1){|x| x})
assert_equal [1, 2, :c, :d, [], Proc, :x], (pr.call(1, 2){|x| x})
assert_equal [1, 2, 3, :d, [], Proc, :x], (pr.call(1, 2, 3){|x| x})
assert_equal [1, 2, 3, 4, [], Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
assert_equal [1, 2, 3, 4, [5], Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
assert_equal [1, 2, 3, 4, [5,6], Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
end
def test_proc_args_pos_opt_rest_post_block
pr = proc {|a,b,c=:c,d=:d,*e,f,g,&h|
[a, b, c, d, e, f, g, h.class, h&&h.call(:x)]
@ -684,6 +922,41 @@ class TestProc < Test::Unit::TestCase
assert_equal [1, 2, 3, 4, [5,6], 7, 8, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7, 8){|x| x})
end
def test_proc_args_opt_rest_post_block
pr = proc {|a=:a,b=:b,c=:c,d=:d,*e,f,g,&h|
[a, b, c, d, e, f, g, h.class, h&&h.call(:x)]
}
assert_equal [:a, :b, :c, :d, [], nil, nil, NilClass, nil], pr.call()
assert_equal [:a, :b, :c, :d, [], 1, nil, NilClass, nil], pr.call(1)
assert_equal [:a, :b, :c, :d, [], 1, 2, NilClass, nil], pr.call(1,2)
assert_equal [1, :b, :c, :d, [], 2, 3, NilClass, nil], pr.call(1,2,3)
assert_equal [1, 2, :c, :d, [], 3, 4, NilClass, nil], pr.call(1,2,3,4)
assert_equal [1, 2, 3, :d, [], 4, 5, NilClass, nil], pr.call(1,2,3,4,5)
assert_equal [1, 2, 3, 4, [], 5, 6, NilClass, nil], pr.call(1,2,3,4,5,6)
assert_equal [1, 2, 3, 4, [5], 6, 7, NilClass, nil], pr.call(1,2,3,4,5,6,7)
assert_equal [1, 2, 3, 4, [5,6], 7, 8, NilClass, nil], pr.call(1,2,3,4,5,6,7,8)
assert_equal [:a, :b, :c, :d, [], nil, nil, Proc, :proc], (pr.call(){ :proc })
assert_equal [:a, :b, :c, :d, [], 1, nil, Proc, :proc], (pr.call(1){ :proc })
assert_equal [:a, :b, :c, :d, [], 1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
assert_equal [1, :b, :c, :d, [], 2, 3, Proc, :proc], (pr.call(1, 2, 3){ :proc })
assert_equal [1, 2, :c, :d, [], 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
assert_equal [1, 2, 3, :d, [], 4, 5, Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
assert_equal [1, 2, 3, 4, [], 5, 6, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6){ :proc })
assert_equal [1, 2, 3, 4, [5], 6, 7, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6, 7){ :proc })
assert_equal [1, 2, 3, 4, [5,6], 7, 8, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6, 7, 8){ :proc })
assert_equal [:a, :b, :c, :d, [], nil, nil, Proc, :x], (pr.call(){|x| x})
assert_equal [:a, :b, :c, :d, [], 1, nil, Proc, :x], (pr.call(1){|x| x})
assert_equal [:a, :b, :c, :d, [], 1, 2, Proc, :x], (pr.call(1, 2){|x| x})
assert_equal [1, :b, :c, :d, [], 2, 3, Proc, :x], (pr.call(1, 2, 3){|x| x})
assert_equal [1, 2, :c, :d, [], 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
assert_equal [1, 2, 3, :d, [], 4, 5, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
assert_equal [1, 2, 3, 4, [], 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
assert_equal [1, 2, 3, 4, [5], 6, 7, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7){|x| x})
assert_equal [1, 2, 3, 4, [5,6], 7, 8, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7, 8){|x| x})
end
def test_proc_args_pos_unleashed
r = proc {|a,b=1,*c,d,e|
[a,b,c,d,e]

View file

@ -833,7 +833,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_post_len) > 0 && /* this process is meaningful */
(m + iseq->arg_opts + iseq->arg_post_len) > 0 && /* 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);