diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-10-01 16:18:03 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-10-01 16:24:36 +0900 |
commit | 56f2fd3bc9bbc69abe75def25f89dac41eb19773 (patch) | |
tree | 628224ab30747d3628485b05c74ebd20a4e6e200 /vm_insnhelper.c | |
parent | 15d3b7fe6dd421cc4ff77d106d17b0e9fd1ead45 (diff) |
Use the dedicated function to check arity
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 98138f5922..03796d2ad1 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -428,16 +428,17 @@ rb_vm_pop_frame(rb_execution_context_t *ec) static inline VALUE rb_arity_error_new(int argc, int min, int max) { - VALUE err_mess = 0; + VALUE err_mess = rb_sprintf("wrong number of arguments (given %d, expected %d", argc, min); if (min == max) { - err_mess = rb_sprintf("wrong number of arguments (given %d, expected %d)", argc, min); + /* max is not needed */ } else if (max == UNLIMITED_ARGUMENTS) { - err_mess = rb_sprintf("wrong number of arguments (given %d, expected %d+)", argc, min); + rb_str_cat_cstr(err_mess, "+"); } else { - err_mess = rb_sprintf("wrong number of arguments (given %d, expected %d..%d)", argc, min, max); + rb_str_catf(err_mess, "..%d", max); } + rb_str_cat_cstr(err_mess, ")"); return rb_exc_new3(rb_eArgError, err_mess); } |