From c4bca7cbb3eda883c7b09b6c0568a90fb8a85a5d Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 28 Nov 2021 18:21:29 +0900 Subject: 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) ``` --- src/vm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src') diff --git a/src/vm.c b/src/vm.c index 65af8dcc0..84ec08cfe 100644 --- a/src/vm.c +++ b/src/vm.c @@ -963,13 +963,7 @@ argnum_error(mrb_state *mrb, mrb_int num) if (argc == 0 && mrb->c->ci->nk != 0 && !mrb_hash_empty_p(mrb, mrb->c->ci->stack[1])) { argc++; } - if (mrb->c->ci->mid) { - str = mrb_format(mrb, "'%n': wrong number of arguments (%i for %i)", - mrb->c->ci->mid, argc, num); - } - else { - str = mrb_format(mrb, "wrong number of arguments (%i for %i)", argc, num); - } + str = mrb_format(mrb, "wrong number of arguments (given %i, expected %i)", argc, num); exc = mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str); mrb_exc_set(mrb, exc); } -- cgit v1.2.3