Project

General

Profile

Actions

Bug #11296

closed

Proc#arity returns weird value for non-lambda proc with optional arguments

Bug #11296: Proc#arity returns weird value for non-lambda proc with optional arguments

Added by matz (Yukihiro Matsumoto) over 10 years ago. Updated over 10 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-dev:49127]

Description

Proc.new(x=0){}.arity returns 0, not -1 unlike lambdas.
I don't remember if it's intentional or not. Anyone remember?

Matz.

Updated by nobu (Nobuyoshi Nakada) over 10 years ago Actions #1 [ruby-dev:49129]

  • Status changed from Open to Feedback

Proc.new(x=0){} raises an ArgumentError for me, in 1.8..2.3.

Updated by Hanmac (Hans Mackowiak) over 10 years ago Actions #2 [ruby-dev:49130]

i think matz means:

Proc.new(){|x=0|}.arity # => 0 
lambda {|x=0|}.arity # => -1 

Updated by znz (Kazuhiro NISHIYAMA) over 10 years ago Actions #3 [ruby-dev:49131]

I think #5694 and #7765 are related issues.

Updated by matz (Yukihiro Matsumoto) over 10 years ago Actions #4 [ruby-dev:49132]

Hans, thank you. That's what I meant.
Kazuhiro, #7765 suggests that seems intentional.
After hearing opnion from others, I will close the issue (unless meaningful discussion starts).

Matz.

Updated by marcandre (Marc-Andre Lafortune) over 10 years ago Actions #5 [ruby-dev:49134]

This is intentional, as per #5694 (note 22). It is not really related to #7765.

FWIW, I still believe it was not the best decision.

Updated by matz (Yukihiro Matsumoto) over 10 years ago Actions #6 [ruby-dev:49137]

  • Status changed from Feedback to Closed

Marc-Andre, thank you for the info. You have made the issue clear.
Now I can safely close the issue.

Matz.

Updated by usa (Usaku NAKAMURA) over 10 years ago Actions #7 [ruby-dev:49150]

  • Status changed from Closed to Rejected
Actions

Also available in: PDF Atom