diff options
| author | dearblue <[email protected]> | 2021-11-28 18:21:29 +0900 |
|---|---|---|
| committer | dearblue <[email protected]> | 2021-11-28 18:21:29 +0900 |
| commit | c4bca7cbb3eda883c7b09b6c0568a90fb8a85a5d (patch) | |
| tree | 48bb84aa1582cbf63332319509d7288bffa7b73f /mrblib | |
| parent | e4d691778676f8cb284c91b8ca72b2dff41e2560 (diff) | |
| download | mruby-c4bca7cbb3eda883c7b09b6c0568a90fb8a85a5d.tar.gz mruby-c4bca7cbb3eda883c7b09b6c0568a90fb8a85a5d.zip | |
Align "wrong number of arguments" messages
Make "N for M" into the form "given N, expected M".
As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message.
I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394.
- Before this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError)
```
- After this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError)
```
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/string.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mrblib/string.rb b/mrblib/string.rb index 2b3178688..81ddf6784 100644 --- a/mrblib/string.rb +++ b/mrblib/string.rb @@ -51,7 +51,7 @@ class String # ISO 15.2.10.5.18 def gsub(*args, &block) return to_enum(:gsub, *args) if args.length == 1 && !block - raise ArgumentError, "wrong number of arguments" unless (1..2).include?(args.length) + raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 1..2)" unless (1..2).include?(args.length) pattern, replace = *args plen = pattern.length |
