Feature #11460 » mod-reopen-error-message.patch
test/ruby/test_class.rb | ||
---|---|---|
def test_redefinition_mismatch
|
||
m = Module.new
|
||
m.module_eval "A = 1"
|
||
assert_raise_with_message(TypeError, /is not a class/) {
|
||
assert_raise_with_message(TypeError, /is not a class, it is a Integer/) {
|
||
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") {
|
||
assert_raise_with_message(TypeError, "#{n} is not a class, it is a Integer") {
|
||
m.module_eval "class #{n}; end"
|
||
}
|
||
test/ruby/test_module.rb | ||
---|---|---|
def test_redefinition_mismatch
|
||
m = Module.new
|
||
m.module_eval "A = 1"
|
||
assert_raise_with_message(TypeError, /is not a module/) {
|
||
assert_raise_with_message(TypeError, /is not a module, it is a Integer/) {
|
||
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") {
|
||
assert_raise_with_message(TypeError, "#{n} is not a module, it is a Integer") {
|
||
m.module_eval "module #{n}; end"
|
||
}
|
||
vm_insnhelper.c | ||
---|---|---|
vm_check_if_class(ID id, rb_num_t flags, VALUE super, VALUE klass)
|
||
{
|
||
if (!RB_TYPE_P(klass, T_CLASS)) {
|
||
rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a class", rb_id2str(id));
|
||
rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a class, it is a %s", rb_id2str(id), rb_builtin_class_name(klass));
|
||
}
|
||
else if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags)) {
|
||
VALUE tmp = rb_class_real(RCLASS_SUPER(klass));
|
||
... | ... | |
vm_check_if_module(ID id, VALUE mod)
|
||
{
|
||
if (!RB_TYPE_P(mod, T_MODULE)) {
|
||
rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a module", rb_id2str(id));
|
||
rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a module, it is a %s", rb_id2str(id), rb_builtin_class_name(mod));
|
||
}
|
||
else {
|
||
return mod;
|