Project

General

Profile

Bug #6086

Number of arguments and named parameters

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

Status:
Rejected
Priority:
Normal
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

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

Also available in: Atom PDF