ruby-changes:32354
From: marcandre <ko1@a...>
Date: Thu, 26 Dec 2013 06:37:58 +0900 (JST)
Subject: [ruby-changes:32354] marcandRe: r44433 (trunk): * proc.c: Having any mandatory keyword argument increases min arity [#9299]
marcandre 2013-12-26 06:36:19 +0900 (Thu, 26 Dec 2013) New Revision: 44433 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44433 Log: * proc.c: Having any mandatory keyword argument increases min arity [#9299] Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_proc.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 44432) +++ ChangeLog (revision 44433) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Dec 26 06:35:25 2013 Marc-Andre Lafortune <ruby-core@m...> + + * proc.c: Having any mandatory keyword argument increases min arity + [#9299] + Thu Dec 26 06:27:08 2013 Marc-Andre Lafortune <ruby-core@m...> * proc.c: Having optional keyword arguments makes maximum arity +1, Index: proc.c =================================================================== --- proc.c (revision 44432) +++ proc.c (revision 44433) @@ -881,7 +881,7 @@ rb_iseq_min_max_arity(const rb_iseq_t *i https://github.com/ruby/ruby/blob/trunk/proc.c#L881 iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0) + (iseq->arg_keyword != -1) : UNLIMITED_ARGUMENTS; - return iseq->argc + iseq->arg_post_len; + return iseq->argc + iseq->arg_post_len + (iseq->arg_keyword_required > 0); } static int Index: test/ruby/test_proc.rb =================================================================== --- test/ruby/test_proc.rb (revision 44432) +++ test/ruby/test_proc.rb (revision 44433) @@ -85,6 +85,11 @@ class TestProc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_proc.rb#L85 assert_equal(2, proc{|x, y=0, z, **o|}.arity) assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity) + assert_equal(2, proc{|x, y=0, z, a:1|}.arity) + assert_equal(3, proc{|x, y=0, z, a:|}.arity) + assert_equal(-4, proc{|x, y, *rest, a:, b:, c:|}.arity) + assert_equal(3, proc{|x, y=0, z, a:, **o|}.arity) + assert_equal(0, lambda{}.arity) assert_equal(0, lambda{||}.arity) assert_equal(1, lambda{|x|}.arity) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/