Bug #7765

Proc#arity bug with optional argument

Added by Marc-Andre Lafortune about 1 year ago. Updated about 1 year ago.

[ruby-core:51785]
Status:Closed
Priority:Normal
Assignee:Marc-Andre Lafortune
Category:core
Target version:2.0.0
ruby -v:r38984 Backport:

Description

We have:

Proc.new{|a, b, c, d, e|}.arity # => 5

Matz decided we also have:

Proc.new{|a, b, c, d, e=0|}.arity # => 4

It looks like we currently have:

Proc.new{|a, b=0, c, d, e|}.arity # => 1, should be same as above

Hopefully there won't be disagreement that this is a bug?

I'm asking in particular because there was a specific test committed by Yui to that effect. I hope this was just an oversight?

assert_equal(0, proc{|x=0, y|}.arity)    # Should be 1, not 0.   test/ruby/test_proc.rb:67

My patch is ready and I will commit it unless there is objection.

https://github.com/marcandre/ruby/compare/marcandre:trunk...marcandre:proc_curry

Associated revisions

Revision 39007
Added by Marc-Andre Lafortune about 1 year ago

  • proc.c: Add {*}minmax_arity and refactor.
    [Bug #7765]

  • test/ruby/test_proc.rb: Fix wrong test

History

#1 Updated by Marc-Andre Lafortune about 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39007.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • proc.c: Add {*}minmax_arity and refactor.
    [Bug #7765]

  • test/ruby/test_proc.rb: Fix wrong test

Also available in: Atom PDF