Project

General

Profile

Bug #14726 ยป subclass-not-class-err-msg-14726.patch

jeremyevans0 (Jeremy Evans), 10/17/2019 10:44 PM

View differences:

class.c
rb_check_inheritable(VALUE super)
{
if (!RB_TYPE_P(super, T_CLASS)) {
rb_raise(rb_eTypeError, "superclass must be a Class (%"PRIsVALUE" given)",
rb_raise(rb_eTypeError, "superclass must be an instance of Class (given an instance of %"PRIsVALUE")",
rb_obj_class(super));
}
if (RBASIC(super)->flags & FL_SINGLETON) {
spec/ruby/core/class/new_spec.rb
end
it "raises a TypeError when given a non-Class" do
error_msg = /superclass must be a Class/
error_msg = /superclass must be a.*Class/
-> { Class.new("") }.should raise_error(TypeError, error_msg)
-> { Class.new(1) }.should raise_error(TypeError, error_msg)
-> { Class.new(:symbol) }.should raise_error(TypeError, error_msg)
vm_insnhelper.c
if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) && !RB_TYPE_P(super, T_CLASS)) {
rb_raise(rb_eTypeError,
"superclass must be a Class (%"PRIsVALUE" given)",
"superclass must be an instance of Class (given an instance of %"PRIsVALUE")",
rb_obj_class(super));
}
    (1-1/1)