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

ruby-changes:38972

From: nobu <ko1@a...>
Date: Mon, 29 Jun 2015 02:07:32 +0900 (JST)
Subject: [ruby-changes:38972] nobu:r51053 (trunk): insns.def: preserve encoding

nobu	2015-06-29 02:06:59 +0900 (Mon, 29 Jun 2015)

  New Revision: 51053

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

  Log:
    insns.def: preserve encoding
    
    * insns.def (defineclass): preserve encoding of name in error
      messages when already defined but type mismatch.

  Modified files:
    trunk/ChangeLog
    trunk/insns.def
    trunk/test/ruby/test_class.rb
    trunk/test/ruby/test_module.rb
Index: insns.def
===================================================================
--- insns.def	(revision 51052)
+++ insns.def	(revision 51053)
@@ -861,7 +861,7 @@ defineclass https://github.com/ruby/ruby/blob/trunk/insns.def#L861
 	    klass = VM_DEFINECLASS_SCOPED_P(flags) ?
 		rb_public_const_get_at(klass, id) : rb_const_get_at(klass, id);
 	    if (!RB_TYPE_P(klass, T_CLASS)) {
-		rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id));
+		rb_raise(rb_eTypeError, "% "PRIsVALUE" is not a class", rb_id2str(id));
 	    }
 
 	    if (super != rb_cObject) {
@@ -899,7 +899,7 @@ defineclass https://github.com/ruby/ruby/blob/trunk/insns.def#L899
 		rb_public_const_get_at(klass, id) : rb_const_get_at(klass, id);
 	    /* already exist */
 	    if (!RB_TYPE_P(klass, T_MODULE)) {
-		rb_raise(rb_eTypeError, "%s is not a module", rb_id2name(id));
+		rb_raise(rb_eTypeError, "% "PRIsVALUE" is not a module", rb_id2str(id));
 	    }
 	}
 	else {
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51052)
+++ ChangeLog	(revision 51053)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 29 02:06:51 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* insns.def (defineclass): preserve encoding of name in error
+	  messages when already defined but type mismatch.
+
 Sun Jun 28 12:07:35 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* class.c (rb_define_class_id_under): raise TypeError exception
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 51052)
+++ test/ruby/test_module.rb	(revision 51053)
@@ -2072,6 +2072,11 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L2072
     assert_raise_with_message(TypeError, /is not a module/) {
       m.module_eval "module A; end"
     }
+    n = "M\u{1f5ff}"
+    m.module_eval "#{n} = 42"
+    assert_raise_with_message(TypeError, "#{n} is not a module") {
+      m.module_eval "module #{n}; end"
+    }
   end
 
   private
Index: test/ruby/test_class.rb
===================================================================
--- test/ruby/test_class.rb	(revision 51052)
+++ test/ruby/test_class.rb	(revision 51053)
@@ -529,5 +529,10 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L529
     assert_raise_with_message(TypeError, /is not a class/) {
       m.module_eval "class A; end"
     }
+    n = "M\u{1f5ff}"
+    m.module_eval "#{n} = 42"
+    assert_raise_with_message(TypeError, "#{n} is not a class") {
+      m.module_eval "class #{n}; end"
+    }
   end
 end

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

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