[前][次][番号順一覧][スレッド一覧]

ruby-changes:50602

From: nobu <ko1@a...>
Date: Thu, 15 Mar 2018 09:12:23 +0900 (JST)
Subject: [ruby-changes:50602] nobu:r62752 (trunk): vm.c: refined error message

nobu	2018-03-15 09:12:17 +0900 (Thu, 15 Mar 2018)

  New Revision: 62752

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62752

  Log:
    vm.c: refined error message
    
    * vm.c (kw_check_symbol): refined the error message for non-symbol
      key.  [Feature #14603]

  Modified files:
    trunk/vm.c
Index: vm.c
===================================================================
--- vm.c	(revision 62751)
+++ vm.c	(revision 62752)
@@ -2742,10 +2742,18 @@ m_core_hash_merge_ptr(int argc, VALUE *a https://github.com/ruby/ruby/blob/trunk/vm.c#L2742
     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 https://github.com/ruby/ruby/blob/trunk/vm.c#L2761
 static int
 kwcheck_i(VALUE key, VALUE value, VALUE hash)
 {
-    Check_Type(key, T_SYMBOL);
+    kw_check_symbol(key);
     return ST_CONTINUE;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]