diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-15 00:12:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-15 00:12:17 +0000 |
commit | 421a73f51a39ff6829f9715b423a928782ec8ec3 (patch) | |
tree | fbcfd294ec36ee2993e0abd05c52fc38712117f4 /vm.c | |
parent | d9abf6efbcde7b4074272a464dd2ebacecfe2575 (diff) |
vm.c: refined error message
* vm.c (kw_check_symbol): refined the error message for non-symbol
key. [Feature #14603]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -2742,10 +2742,18 @@ m_core_hash_merge_ptr(int argc, VALUE *argv, VALUE recv) return hash; } +static void +kw_check_symbol(VALUE key) +{ + if (!SYMBOL_P(key)) { + rb_raise(rb_eTypeError, "hash key %+"PRIsVALUE" is not a Symbol", + key); + } +} static int kwmerge_i(VALUE key, VALUE value, VALUE hash) { - Check_Type(key, T_SYMBOL); + kw_check_symbol(key); rb_hash_aset(hash, key, value); return ST_CONTINUE; } @@ -2753,7 +2761,7 @@ kwmerge_i(VALUE key, VALUE value, VALUE hash) static int kwcheck_i(VALUE key, VALUE value, VALUE hash) { - Check_Type(key, T_SYMBOL); + kw_check_symbol(key); return ST_CONTINUE; } |