"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 `’: 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.

On Sun, Oct 20, 2013 at 6:01 PM, Love U Ruby [email protected]
wrote:

Below part is happening as expected :

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.

Xavier N. wrote in post #1125043:

On Sun, Oct 20, 2013 at 6:01 PM, Love U Ruby [email protected]
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?

rand_id = rand([email protected]) @abc =
@abc.hits[rand_id].primary_key.to_i

i am getting an no implicit conversion from nil to integer .please
suggest any solution

error is coming from the C code inside the Ruby interpreter. A core
class, implemented in C, is being handed a nil when it expects an
Integer. It may have a #to_i but it doesn’t have a #to_int and so the
result is the TypeError.

but how can i change there please suggest solution…

On Mon, Oct 21, 2013 at 9:42 PM, Love U Ruby [email protected]
wrote:

Xavier N. wrote in post #1125043:

On Sun, Oct 20, 2013 at 6:01 PM, Love U Ruby [email protected]
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs