Ticket #882 (closed bug: fixed)
SUPER() not handled correctly for DynPMCs
Reported by: | flh | Owned by: | cotto |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | pmc2c | Version: | trunk |
Severity: | medium | Keywords: | |
Cc: | Language: | ||
Patch status: | new | Platform: | all |
Description
- Write a base dynpmc foo, and second dynpmc bar which extends the first one.
- Add a init vtable function (or any other) to both dynpmcs.
- In the second (bar) dynpmc's init, call SUPER().
Compilation of the bar dynpmc fails: the compiler complains that enum_class_foo is undefined (this identifier only exists for regular PMCs).
pmc2c actually rewrites SUPER() in the following way:
interp->vtables[enum_class_foo]->init(interp, pmc);
while we would expect something like that in the case of dynpmcs:
Parrot_foo_get_vtable(interp)->init(interp, pmc);
The attached patch fixes that, by checking in MethodEmitted.pm whether the parent PMC is dynamic or not. make test, make fulltest and Rakudo's make test pass.
This patch does not change the emitted code in the case where foo extends a regular PMC and doesn't implement the overridden function (in which case, we can directly emit interp->vtables[enum_class_regular_base_pmc]->init(interp, pmc);).
I don't know if I should also change the code for DYNSUPER, since I'm not sure about DYNSUPER's semantics.