diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | insns.def | 4 | ||||
-rw-r--r-- | test/ruby/test_class.rb | 5 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 5 |
4 files changed, 17 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Mon Jun 29 02:06:51 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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@ruby-lang.org> * class.c (rb_define_class_id_under): raise TypeError exception @@ -861,7 +861,7 @@ defineclass 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 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 { diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index efee102835..4f7e037580 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -529,5 +529,10 @@ class TestClass < Test::Unit::TestCase 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 diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index e91d2c8a93..5fc3d4a541 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -2072,6 +2072,11 @@ class TestModule < Test::Unit::TestCase 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 |