mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
4b6a0ae306
commit
b8b43fbdbe
4 changed files with 15 additions and 9 deletions
|
@ -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
|
||||
|
|
5
proc.c
5
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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue