Project

General

Profile

Actions

Bug #6086

closed

Number of arguments and named parameters

Added by marcandre (Marc-Andre Lafortune) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Target version:
ruby -v:
r34800
Backport:
[ruby-core:42908]

Description

While working on the messages of "wrong number of arguments" error (see #6085), I realized that the new named parameter feature can lead to misleading error messages:

def foo(x: 42)
end

arg = {x: :bar}
foo(arg) # => nil (no error)
arg = :bar
foo(arg) # => ArgumentError: wrong number of arguments (1 for 0)

It would be better if the wording was changed for methods accepting options. Maybe something like:

foo(arg) # => ArgumentError: wrong number of arguments (1 for 0 **)

Suggestions?


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #6085: Treatment of Wrong Number of ArgumentsClosedmame (Yusuke Endoh)02/25/2012Actions
Related to Ruby master - Feature #5474: keyword argumentClosedmame (Yusuke Endoh)10/23/2011Actions
Actions #1

Updated by ko1 (Koichi Sasada) over 12 years ago

  • Assignee set to mame (Yusuke Endoh)
Actions #2

Updated by shyouhei (Shyouhei Urabe) over 12 years ago

  • Status changed from Open to Assigned
Actions #3

Updated by mame (Yusuke Endoh) over 12 years ago

  • Assignee changed from mame (Yusuke Endoh) to matz (Yukihiro Matsumoto)

Matz, what do you think?

I'm not against this. But I'm not sure how surprising this behavior is,
until I encounter it in actual use case.
"(1 for 0 **)" is not very good-looking, but I have no alternative idea.

--
Yusuke Endoh

Updated by matz (Yukihiro Matsumoto) over 12 years ago

  • Status changed from Assigned to Rejected

Even though I understand the point, I am against the expression "(1 for 0 **)".
So until some one come up with better expression, we leave this as it is now.

Matz.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0