summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-01 12:01:29 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-01 12:01:29 +0000
commitb8b43fbdbea07bfa8e0f2d3ca65871d80b7c903e (patch)
tree203d6832ec5bef116d35898d9b981576822fef2e
parent4b6a0ae306f995d7bec668cf8e046c01defc641b (diff)
merge revision(s) 44432: [Backport #9299]
* proc.c: Having optional keyword arguments makes maximum arity +1, not unlimited [#8072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--proc.c5
-rw-r--r--test/ruby/test_proc.rb12
-rw-r--r--version.h2
4 files changed, 15 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index f2592eb9f6..819c6fe4f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Mar 1 21:00:27 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
+
+ * proc.c: Having optional keyword arguments makes maximum arity +1,
+ not unlimited [#8072]
+
Sat Mar 1 17:25:12 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* proc.c: Having any mandatory keyword argument increases min arity
diff --git a/proc.c b/proc.c
index 9c88ada316..e3cecb7bbe 100644
--- a/proc.c
+++ b/proc.c
@@ -825,8 +825,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 + (iseq->arg_keyword_required > 0);
}
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 9e8fb06d6d..1c8a053cca 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(2, proc{|x, y=0, z, a:1|}.arity)
diff --git a/version.h b/version.h
index 59c80e3828..746643bda1 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-03-01"
-#define RUBY_PATCHLEVEL 79
+#define RUBY_PATCHLEVEL 80
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 3