mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert of r36411, as does not distinguish proc from lambda
* proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments [bug #5694] [rubyspec:b8b259] [rubyspec:184c8100f] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e18c8ebb2
commit
43395d53c9
3 changed files with 9 additions and 18 deletions
|
@ -1,11 +1,3 @@
|
|||
Tue Jul 17 00:18:41 2012 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
Revert r33924.
|
||||
|
||||
* proc.c (rb_proc_arity): Fix Proc#arity in case of optional
|
||||
arguments
|
||||
[bug #5694] [rubyspec:b8b259] [rubyspec:184c8100f]
|
||||
|
||||
Mon Jul 16 23:20:24 2012 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (rb_integer_float_cmp): use FIXNUM_MIN and FIXNUM_MAX,
|
||||
|
|
18
proc.c
18
proc.c
|
@ -622,14 +622,14 @@ rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
|
|||
* arguments. A <code>proc</code> with no argument declarations
|
||||
* is the same a block declaring <code>||</code> as its arguments.
|
||||
*
|
||||
* Proc.new {}.arity #=> 0
|
||||
* Proc.new {||}.arity #=> 0
|
||||
* Proc.new {|a|}.arity #=> 1
|
||||
* Proc.new {|a, b|}.arity #=> 2
|
||||
* Proc.new {|a, b, c|}.arity #=> 3
|
||||
* Proc.new {|*a|}.arity #=> -1
|
||||
* Proc.new {|a, b=42|}.arity #=> -2
|
||||
* Proc.new {|a, *b, c|}.arity #=> -3
|
||||
* Proc.new {}.arity #=> 0
|
||||
* Proc.new {||}.arity #=> 0
|
||||
* Proc.new {|a|}.arity #=> 1
|
||||
* Proc.new {|a,b|}.arity #=> 2
|
||||
* Proc.new {|a,b,c|}.arity #=> 3
|
||||
* Proc.new {|*a|}.arity #=> -1
|
||||
* Proc.new {|a,*b|}.arity #=> -2
|
||||
* Proc.new {|a,*b, c|}.arity #=> -3
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -648,7 +648,7 @@ rb_proc_arity(VALUE self)
|
|||
iseq = proc->block.iseq;
|
||||
if (iseq) {
|
||||
if (BUILTIN_TYPE(iseq) != T_NODE) {
|
||||
if (iseq->arg_rest < 0 && iseq->arg_opts == 0) {
|
||||
if (iseq->arg_rest < 0) {
|
||||
return iseq->argc;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -68,7 +68,6 @@ class TestProc < Test::Unit::TestCase
|
|||
assert_equal(-1, proc{|*|}.arity)
|
||||
assert_equal(-3, proc{|x, *y, z|}.arity)
|
||||
assert_equal(-4, proc{|x, *y, z, a|}.arity)
|
||||
assert_equal(-1, ->(a=42){}.arity)
|
||||
|
||||
assert_arity(0) {}
|
||||
assert_arity(0) {||}
|
||||
|
|
Loading…
Add table
Reference in a new issue