mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* proc.c (rb_proc_arity): return normal value (not -n-1) if it is not
a labmda, or it is a labmda and no arg_opts. [Bug #5694] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7d1f53e782
commit
c2bcae864e
2 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Jul 17 16:41:32 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* proc.c (rb_proc_arity): return normal value (not -n-1) if it is not
|
||||
a labmda, or it is a labmda and no arg_opts. [Bug #5694]
|
||||
|
||||
Tue Jul 17 03:56:34 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/lib/psych/visitors/to_ruby.rb: strings with YAML anchors
|
||||
|
|
6
proc.c
6
proc.c
|
@ -630,6 +630,10 @@ rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
|
|||
* Proc.new {|*a|}.arity #=> -1
|
||||
* Proc.new {|a,*b|}.arity #=> -2
|
||||
* Proc.new {|a,*b, c|}.arity #=> -3
|
||||
* lambda { |a = 0| }.arity #=> -1
|
||||
* lambda { |a, b = 0| }.arity #=> -2
|
||||
* lambda { |a, b = 0, c = 0| }.arity #=> -2
|
||||
* lambda { |(a, b), c = 0| }.arity #=> -2
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -648,7 +652,7 @@ rb_proc_arity(VALUE self)
|
|||
iseq = proc->block.iseq;
|
||||
if (iseq) {
|
||||
if (BUILTIN_TYPE(iseq) != T_NODE) {
|
||||
if (iseq->arg_rest < 0) {
|
||||
if (iseq->arg_rest < 0 && (!proc->is_lambda || iseq->arg_opts == 0)) {
|
||||
return iseq->argc;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue