8000 merge revision(s) 44432: [Backport #9299] · github/ruby@3159b64 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3159b64

Browse files
committed
merge revision(s) 44432: [Backport ruby#9299]
* proc.c: Having optional keyword arguments makes maximum arity +1, not unlimited [ruby#8072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent d5c45b5 commit 3159b64

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sat Mar 1 21:00:27 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
2+
3+
* proc.c: Having optional keyword arguments makes maximum arity +1,
4+
not unlimited [#8072]
5+
16
Sat Mar 1 17:25:12 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
27

38
* proc.c: Having any mandatory keyword argument increases min arity

proc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,9 @@ proc_arity(VALUE self)
825825
static inline int
826826
rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max)
827827
{
828-
*max = (iseq->arg_rest == -1 && iseq->arg_keyword == -1) ?
829-
iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0)
828+
*max = iseq->arg_rest == -1 ?
829+
iseq->argc + iseq->arg_post_len + iseq->arg_opts -
830+
(iseq->arg_opts > 0) + (iseq->arg_keyword != -1)
830831
: UNLIMITED_ARGUMENTS;
831832
return iseq->argc + iseq->arg_post_len + (iseq->arg_keyword_required > 0);
832833
}

test/ruby/test_proc.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ def test_arity
7777
assert_equal(2, proc{|(x, y), z|[x,y]}.arity)
7878
assert_equal(1, proc{|(x, y), z=0|[x,y]}.arity)
7979
assert_equal(-4, proc{|x, *y, z, a|}.arity)
80-
assert_equal(-1, proc{|**|}.arity)
81-
assert_equal(-1, proc{|**o|}.arity)
82-
assert_equal(-2, proc{|x, **o|}.arity)
83-
assert_equal(-1, proc{|x=0, **o|}.arity)
84-
assert_equal(-2, proc{|x, y=0, **o|}.arity)
85-
assert_equal(-3, proc{|x, y=0, z, **o|}.arity)
80+
assert_equal(0, proc{|**|}.arity)
81+
assert_equal(0, proc{|**o|}.arity)
82+
assert_equal(1, proc{|x, **o|}.arity)
83+
assert_equal(0, proc{|x=0, **o|}.arity)
84+
assert_equal(1, proc{|x, y=0, **o|}.arity)
85+
assert_equal(2, proc{|x, y=0, z, **o|}.arity 8F83 )
8686
assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity)
8787

8888
assert_equal(2, proc{|x, y=0, z, a:1|}.arity)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.2"
22
#define RUBY_RELEASE_DATE "2014-03-01"
3-
#define RUBY_PATCHLEVEL 79
3+
#define RUBY_PATCHLEVEL 80
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 3

0 commit comments

Comments
 (0)
0