diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | proc.c | 5 | ||||
-rw-r--r-- | test/ruby/test_proc.rb | 12 |
3 files changed, 14 insertions, 8 deletions
@@ -1,3 +1,8 @@ +Thu Dec 26 06:27:08 2013 Marc-Andre Lafortune <[email protected]> + + * proc.c: Having optional keyword arguments makes maximum arity +1, + not unlimited [#8072] + Thu Dec 26 01:09:57 2013 NAKAMURA Usaku <[email protected]> * tool/release.sh: make symbolic links. @@ -877,8 +877,9 @@ proc_arity(VALUE self) static inline int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) { - *max = (iseq->arg_rest == -1 && iseq->arg_keyword == -1) ? - iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0) + *max = iseq->arg_rest == -1 ? + 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; } diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 206e21fb1a..6c92f1e374 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -77,12 +77,12 @@ class TestProc < Test::Unit::TestCase assert_equal(2, proc{|(x, y), z|[x,y]}.arity) assert_equal(1, proc{|(x, y), z=0|[x,y]}.arity) assert_equal(-4, proc{|x, *y, z, a|}.arity) - assert_equal(-1, proc{|**|}.arity) - assert_equal(-1, proc{|**o|}.arity) - assert_equal(-2, proc{|x, **o|}.arity) - assert_equal(-1, proc{|x=0, **o|}.arity) - assert_equal(-2, proc{|x, y=0, **o|}.arity) - assert_equal(-3, proc{|x, y=0, z, **o|}.arity) + assert_equal(0, proc{|**|}.arity) + assert_equal(0, proc{|**o|}.arity) + assert_equal(1, proc{|x, **o|}.arity) + assert_equal(0, proc{|x=0, **o|}.arity) + assert_equal(1, proc{|x, y=0, **o|}.arity) + assert_equal(2, proc{|x, y=0, z, **o|}.arity) assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity) assert_equal(0, lambda{}.arity) |