mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
3ed6f43b96
commit
491ace2dbe
4 changed files with 17 additions and 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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue