diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-07-07 18:59:38 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-07-07 18:59:38 +0000 |
commit | c016898e79edec4fe3c5106ba7e7742a5eaa3f17 (patch) | |
tree | 58f7c1aac414fceb00a3d5bdc1f003406d610c9c | |
parent | e4d4172befce67da1b7ef54848f2acd7c1febc72 (diff) |
* vm_args.c (setup_parameters_complex): don't raise ArgumentError
if an array is given for instance_exec with optional argument.
[ruby-core:76300] [Bug #12568]
https://github.com/rails/rails/pull/25699
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | test/ruby/test_lambda.rb | 7 | ||||
-rw-r--r-- | vm_args.c | 1 |
3 files changed, 15 insertions, 0 deletions
@@ -1,3 +1,10 @@ +Fri Jul 8 03:54:22 2016 NARUSE, Yui <naruse@ruby-lang.org> + + * vm_args.c (setup_parameters_complex): don't raise ArgumentError + if an array is given for instance_exec with optional argument. + [ruby-core:76300] [Bug #12568] + https://github.com/rails/rails/pull/25699 + Fri Jul 8 00:47:36 2016 NARUSE, Yui <naruse@ruby-lang.org> * vm_eval.c (yield_under): change prototype to get argc/argv. diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index efc3d0f2ca..c65169ac27 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -72,6 +72,13 @@ class TestLambdaParameters < Test::Unit::TestCase assert_raise(ArgumentError, bug9605) {proc(&plus).call [1,2]} end + def test_instance_exec + bug12568 = '[ruby-core:76300] [Bug #12568]' + assert_nothing_raised(ArgumentError, bug12568) do + instance_exec([1,2,3], &->(a=[]){ a }) + end + end + def yield_1(arg) yield arg end @@ -587,6 +587,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq, case arg_setup_lambda: if (given_argc == 1 && given_argc != iseq->body->param.lead_num && + !iseq->body->param.flags.has_opt && !iseq->body->param.flags.has_rest && args_check_block_arg0(args, th)) { given_argc = RARRAY_LENINT(args->rest); |