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

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
This commit is contained in:
nobu 2018-03-15 00:12:17 +00:00
parent d9abf6efbc
commit 421a73f51a

12
vm.c
View file

@ -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;
}