diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-08 07:19:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-08 07:19:30 +0000 |
commit | dd8710d243f756ea446ae6f92f72c9e41755fd77 (patch) | |
tree | 88eacf942f0045896a9eff5d49139b5815df01cc /class.c | |
parent | 72f60a2ff1900295b1ff8d10b63b045152475d4f (diff) |
class.c, vm_insnhelper.c: check unknown keywords
* class.c (rb_get_kwargs): if optional is negative, unknown
keywords are allowed.
* vm_insnhelper.c (vm_callee_setup_keyword_arg): check unknown
keywords.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1912,8 +1912,13 @@ int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values) { int i = 0, j; + int rest = 0; VALUE missing = Qnil; + if (optional < 0) { + rest = 1; + optional = -1-optional; + } if (values) { for (j = 0; j < required + optional; j++) { values[j] = Qundef; @@ -1945,6 +1950,8 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V j++; } } + } + if (!rest && keyword_hash) { if (RHASH_SIZE(keyword_hash) > (unsigned int)j) { unknown_keyword_error(keyword_hash, table, required+optional); } |