aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 5ab1eac1ea..1fdf330632 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -136,9 +136,17 @@ NORETURN(static void unknown_keyword_error(const rb_iseq_t *iseq, VALUE hash));
static void
unknown_keyword_error(const rb_iseq_t *iseq, VALUE hash)
{
- (void) iseq;
- (void) hash;
- rb_raise(rb_eArgError, "unknown keyword");
+ VALUE sep = rb_usascii_str_new2(", "), keys;
+ const char *msg;
+ int i;
+ for (i = 0; i < iseq->arg_keywords; i++) {
+ rb_hash_delete(hash, ID2SYM(iseq->arg_keyword_table[i]));
+ }
+ keys = rb_funcall(hash, rb_intern("keys"), 0, 0);
+ if (TYPE(keys) != T_ARRAY) rb_raise(rb_eArgError, "unknown keyword");
+ msg = RARRAY_LEN(keys) == 1 ? "unknown keyword: %s" : "unknown keywords: %s";
+ keys = rb_funcall(keys, rb_intern("join"), 1, sep);
+ rb_raise(rb_eArgError, msg, RSTRING_PTR(keys));
}
#define VM_CALLEE_SETUP_ARG(ret, th, iseq, orig_argc, orig_argv, block) \