aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 21:36:19 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 21:36:19 +0000
commit64f0682d7da858cf49c5559513a838248f8efee5 (patch)
tree2b7f166ad0ee8d54247fc34879a8e451ac4e376a
parent43c3f447a4d442e0b135220013c89f3742645b37 (diff)
downloadruby-64f0682d7da858cf49c5559513a838248f8efee5.tar.gz
* proc.c: Having any mandatory keyword argument increases min arity [#9299]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--proc.c2
-rw-r--r--test/ruby/test_proc.rb5
3 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0c22cfcdbf..3cda6e3ce7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 26 06:35:25 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
+
+ * proc.c: Having any mandatory keyword argument increases min arity
+ [#9299]
+
Thu Dec 26 06:27:08 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* proc.c: Having optional keyword arguments makes maximum arity +1,
diff --git a/proc.c b/proc.c
index 82f9e38ff2..1b61d71ac1 100644
--- a/proc.c
+++ b/proc.c
@@ -881,7 +881,7 @@ rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max)
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
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 6c92f1e374..1c8a053cca 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -85,6 +85,11 @@ class TestProc < Test::Unit::TestCase
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)