[perl #59630] [BUG] Complex subtraction fails for subclasses of Complex

Allison Randal via RT parrotbug-followup at parrotcode.org
Tue Oct 7 11:13:56 UTC 2008


The fundamental problem here is that both 'VTABLE_morph' and 'pmc_new'
are trying to use 'SELF->vtable->base_type' as the type number of the
PMC to create. But, with the Object PMC, that gives the type number of
the Object PMC itself (63) instead of the type number of the PIR class
the object was instantiated from. (That's why you got the error "Object
must be created by a class.", because it was trying to directly create
an Object PMC, which should never happen.)

Most places you see 'some_pmc->vtable->base_type' it should be
'VTABLE_type(INTERP, some_pmc)' instead, which gives the correct answer
for Class, Object, and any other PMC that overrides type for more
advanced purposes. I converted some of these in the MMD branch, but
definitely didn't catch them all.

On whether 'subtract' (or any of the core numeric PMCs) should call
VTABLE_morph on the destination or just create a new destination, the
answer is that core PMCs should create a new destination. The few
remaining VTABLE_morph calls on destination PMCs are bits I missed in
the conversion.

Allison


More information about the parrot-dev mailing list