From 491ace2dbebcba5e6f36b9e877c585823fd583f1 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 28 Jun 2015 17:06:59 +0000 Subject: insns.def: preserve encoding * insns.def (defineclass): preserve encoding of name in error messages when already defined but type mismatch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ insns.def | 4 ++-- test/ruby/test_class.rb | 5 +++++ test/ruby/test_module.rb | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a28e7f1340..f3bd909307 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jun 29 02:06:51 2015 Nobuyoshi Nakada + + * 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 * class.c (rb_define_class_id_under): raise TypeError exception diff --git a/insns.def b/insns.def index 356a0677c6..dd6e8e24b5 100644 --- a/insns.def +++ b/insns.def @@ -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 -- cgit v1.2.3