summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-21 19:51:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-21 19:51:19 +0000
commit79f7dfabb69ec435b6b0be5ccb5157cb85e71580 (patch)
tree8188d7372f9774ce1b9cfddcf2e4e7a189614127 /vm_insnhelper.c
parent7e052c7b81d22fe4556e313c1f24ccda15502ab1 (diff)
vm_insnhelper.c: check required kwarg with resthash
* vm_insnhelper.c (vm_callee_setup_keyword_arg): should check required keyword arguments even if rest hash is defined. [ruby-core:53608] [Bug #8139] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index a6b307048a..b1c48faf03 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1080,9 +1080,10 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, VALUE *orig_argv, V
!NIL_P(keyword_hash = rb_check_hash_type(orig_argv[argc-1]))) {
argc--;
keyword_hash = rb_hash_dup(keyword_hash);
- if (iseq->arg_keyword_check) {
+ i = 0;
+ if (iseq->arg_keyword_required) {
VALUE missing = Qnil;
- for (i = 0; i < iseq->arg_keyword_required; i++) {
+ for (; i < iseq->arg_keyword_required; i++) {
if (st_lookup(RHASH_TBL(keyword_hash), ID2SYM(iseq->arg_keyword_table[i]), 0))
continue;
if (NIL_P(missing)) missing = rb_ary_tmp_new(1);
@@ -1091,6 +1092,8 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, VALUE *orig_argv, V
if (!NIL_P(missing)) {
keyword_error("missing", missing);
}
+ }
+ if (iseq->arg_keyword_check) {
for (j = i; i < iseq->arg_keywords; i++) {
if (st_lookup(RHASH_TBL(keyword_hash), ID2SYM(iseq->arg_keyword_table[i]), 0)) j++;
}
@@ -1099,7 +1102,7 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, VALUE *orig_argv, V
}
}
}
- else if (iseq->arg_keyword_check && iseq->arg_keyword_required) {
+ else if (iseq->arg_keyword_required) {
VALUE missing = rb_ary_tmp_new(iseq->arg_keyword_required);
for (i = 0; i < iseq->arg_keyword_required; i++) {
rb_ary_push(missing, ID2SYM(iseq->arg_keyword_table[i]));