Project

General

Profile

Actions

Feature #9025

closed

Clarify the error message when calling a method with the wrong number of arguments

Added by Nerian (Gonzalo Rodríguez) over 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:<unknown>]

Description

Currently when calling a method with the wrong number of arguments we get a confusing error message:

ArgumentError: wrong number of arguments (1 for 0)

That means that the method was meant to accept 0 arguments, but 1 was provided instead. This error message is confusing, and a large number of people had to search for its meaning. For example [1] has 11000 views.

I propose that we change the error message to something whose meaning is obvious. Examples:

  • ArgumentError: wrong number of arguments (expected: 1, provided: 0)
  • ArgumentError: wrong number of arguments (1 instead of 0)

This ticket originated from this pull request: https://github.com/ruby/ruby/pull/367

[1] http://stackoverflow.com/questions/7537450/what-does-wrong-number-of-arguments-1-for-0-mean-in-ruby


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #11617: Fix tests for Feature 9025Closednobu (Nobuyoshi Nakada)Actions
Actions

Also available in: Atom PDF