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
220 220
rb_check_inheritable(VALUE super)
221 221
{
222 222
    if (!RB_TYPE_P(super, T_CLASS)) {
223
	rb_raise(rb_eTypeError, "superclass must be a Class (%"PRIsVALUE" given)",
223
        rb_raise(rb_eTypeError, "superclass must be an instance of Class (given an instance of %"PRIsVALUE")",
224 224
		 rb_obj_class(super));
225 225
    }
226 226
    if (RBASIC(super)->flags & FL_SINGLETON) {
spec/ruby/core/class/new_spec.rb
95 95
  end
96 96

  
97 97
  it "raises a TypeError when given a non-Class" do
98
    error_msg = /superclass must be a Class/
98
    error_msg = /superclass must be a.*Class/
99 99
    -> { Class.new("")         }.should raise_error(TypeError, error_msg)
100 100
    -> { Class.new(1)          }.should raise_error(TypeError, error_msg)
101 101
    -> { Class.new(:symbol)    }.should raise_error(TypeError, error_msg)
vm_insnhelper.c
3596 3596

  
3597 3597
    if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) && !RB_TYPE_P(super, T_CLASS)) {
3598 3598
	rb_raise(rb_eTypeError,
3599
		 "superclass must be a Class (%"PRIsVALUE" given)",
3599
                 "superclass must be an instance of Class (given an instance of %"PRIsVALUE")",
3600 3600
		 rb_obj_class(super));
3601 3601
    }
3602 3602

  
3603
-