"Type Error" not coming when trying to make a class as subclass of Object

Below part is happening as expected :

class A;end
class C;end
class B<A;end
class B<C;end
# ~> -:4:in `<main>': superclass mismatch for class B (Type Error)

why not the same is happened for the below part ?

class A;end
class B<A;end
class B<Object;end # expeted error here as above.
B.superclass # => A #still the super class is showing as A.

···

--
Posted via http://www.ruby-forum.com/.

Below part is happening as expected :

class A;end
class C;end
class B<A;end
class B<C;end
# ~> -:4:in `<main>': superclass mismatch for class B (Type Error)

why not the same is happened for the below part ?

class A;end
class B<A;end
class B<Object;end # expeted error here as above.
B.superclass # => A #still the super class is showing as A.

The implementation of that behavior is here:

    https://github.com/ruby/ruby/blob/trunk/insns.def#L912-L929

I don't know the rationale behind that.

If I had to bet one dollar and conjecture something :), I'd say that is
done that way so that you do not need to specify again the superclass when
you reopen a class (think class_eval with a different scope).

But then, I believe this is not consistent and there's a bug. If that was
the motivation (hypothesis), then I'd expect the following:

1) If no superclass is specified, then just reopen.

2) If a superclass is specified, then validate it.

But 1) is not implemented that way, it bypasses the check if super is
Object (either implicit or explicit). I think that is suspicious.

···

On Sun, Oct 20, 2013 at 6:01 PM, Love U Ruby <lists@ruby-forum.com> wrote:

Xavier Noria wrote in post #1125043:

···

On Sun, Oct 20, 2013 at 6:01 PM, Love U Ruby <lists@ruby-forum.com> > wrote:

But 1) is not implemented that way, it bypasses the check if super is
Object (either implicit or explicit). I think that is suspicious.

Thanks Xavier

Shall I submit it as a bug?

--
Posted via http://www.ruby-forum.com/\.

Xavier Noria wrote in post #1125043:

···

On Mon, Oct 21, 2013 at 9:42 PM, Love U Ruby <lists@ruby-forum.com> wrote:

> On Sun, Oct 20, 2013 at 6:01 PM, Love U Ruby <lists@ruby-forum.com> > > wrote:

> But 1) is not implemented that way, it bypasses the check if super is
> Object (either implicit or explicit). I think that is suspicious.

Thanks Xavier

Shall I submit it as a bug?

I think so. It could be a good opportunity to try to contribute a patch
even, probably having a look at the existing code and tests this proposal
shouldn't need a small amount of code.