Permalink
Browse files

Add proper given argument number in the wrong-number-argument error.

  • Loading branch information...
matz committed Jan 12, 2017
1 parent a357124 commit 8d61f2120c7b3c637ce61df4c13e4b066029a4d5
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/vm.c
View
@@ -717,15 +717,22 @@ argnum_error(mrb_state *mrb, mrb_int num)
{
mrb_value exc;
mrb_value str;
mrb_int argc = mrb->c->ci->argc;
if (argc < 0) {
mrb_value args = mrb->c->stack[1];
if (mrb_array_p(args)) {
argc = RARRAY_LEN(args);
}
}
if (mrb->c->ci->mid) {
str = mrb_format(mrb, "'%S': wrong number of arguments (%S for %S)",
mrb_sym2str(mrb, mrb->c->ci->mid),
mrb_fixnum_value(mrb->c->ci->argc), mrb_fixnum_value(num));
mrb_fixnum_value(argc), mrb_fixnum_value(num));
}
else {
str = mrb_format(mrb, "wrong number of arguments (%S for %S)",
mrb_fixnum_value(mrb->c->ci->argc), mrb_fixnum_value(num));
mrb_fixnum_value(argc), mrb_fixnum_value(num));
}
exc = mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str);
mrb_exc_set(mrb, exc);

0 comments on commit 8d61f21

Please sign in to comment.