1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
mame 2011-12-26 14:20:20 +00:00
parent d0baa0dd52
commit c5e372ff27
2 changed files with 18 additions and 4 deletions

View file

@ -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.

View file

@ -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) \