summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-26 14:20:20 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-26 14:20:20 +0000
commitc5e372ff277af2b69c785290389f638dbfef820d (patch)
treeea60655d29f59060254f403f5cef879b4713c280
parentd0baa0dd52fb1d72e23633bb2ba5a551957a4776 (diff)
* vm_insnhelper.c (unknown_keyword_error): make it kind a error message when unknown keyword is given. It require more work. See [ruby-core:40518] and [ruby-core:40541] in detail.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--vm_insnhelper.c14
2 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c908f8..d421589 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,16 @@
+Mon Dec 26 22:38:35 2011 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * vm_insnhelper.c (unknown_keyword_error): make it kind a error
+ message when unknown keyword is given. It require more work.
+ See [ruby-core:40518] and [ruby-core:40541] in detail.
+
Mon Dec 26 22:31:07 2011 Yusuke Endoh <mame@tsg.ne.jp>
* vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments),
iseq.c (rb_iseq_parameters), vm_insnhelper.c
(vm_callee_setup_arg_complex): support Method#parameters for keyword
arguments. The provisional spec is what Benoit Daloze proposed.
- [ruby-core:40518]
+ [ruby-core:40541]
* test/ruby/test_keyword.rb: add a test for above.
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 5ab1eac..1fdf330 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) \