Chaos Project

Featured Projects => Tasks => Advanced RPG Creator => Finished Tasks => Topic started by: Blizzard on May 15, 2011, 06:01:56 pm

Title: [Finished] [RGSS] Error: "superclass mismatch"
Post by: Blizzard on May 15, 2011, 06:01:56 pm
Error: "superclass mismatch"




Description

When changing the superclass of a class without first undefining the that class, Ruby 1.9.x will throw an error. There has to be a way to circumvent this problem. Otherwise it will be necessary to rewrite (even if only slightly) a lot of scripts and people don't want that. One of ARC's main selling points is that it is compatible with RMXP scripts, regardless of anything.
I have researched the problem already, but I couldn't find anything.



Priority

Critical.



Prerequisites

None



Assigned

ForeverZer0
Blizzard



Everything else

This piece of code illustrates the problem:
class A
end
class B
end
class C < A
end
class C < B # throws "TypeError: superclass mismatch"
end
Title: Re: Error: "superclass mismatch"
Post by: ForeverZer0 on May 15, 2011, 06:03:59 pm
Holy shit, I didn't realize newer versions of Ruby did that. That really sucks.
I'll see what I can do.
Title: Re: Error: "superclass mismatch"
Post by: Blizzard on May 15, 2011, 06:17:08 pm
I mean, it makes sense to do that. But sadly there are scripts (including my own) that won't work with that.
Title: Re: Error: "superclass mismatch"
Post by: ForeverZer0 on May 15, 2011, 08:08:51 pm
Its not looking good on this one for doing through Ruby. For some reason Ruby decided to go out of its way to prevent this, and it is only possible with modules using "include", but then you lose the metaclass inheritance.

I'm gonna keep trying myself, and do some extensive google work to see what I can come up with.
Title: Re: Error: "superclass mismatch"
Post by: nathmatt on May 15, 2011, 09:26:28 pm
heres something but im not sure if it removes the entire definition
here (http://rpheath.com/posts/373-ruby-error-superclass-mismatch)
Title: Re: Error: "superclass mismatch"
Post by: ForeverZer0 on May 15, 2011, 09:40:11 pm
We need a way for it to do that automatically, without knowing the classes ahead of time.

I think we need to find a way of using an intermediate metaclass, but I foresee errors there too.
Title: Re: Error: "superclass mismatch"
Post by: Blizzard on May 16, 2011, 11:40:39 am
I can use something like "Object.send(:remove_const, :Game_Player)", that's not the problem. As F0 said, we need an automatic way to do this.

If you can't find anything, I'll try to find that part in the Ruby source, just delete it and compile Ruby without it. Or I can add the constant removal there, it doesn't matter. Though, I'd like to avoid poking around in Ruby's source.

EDIT: Alright, I have simple commented out that piece of code and recompiled Ruby. Task finished.