Ticket #882 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

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.

Attachments

pmc2c_super_dynpmc.patch Download (0.8 KB) - added by flh 5 years ago.

Change History

Changed 5 years ago by flh

Changed 5 years ago by cotto

  • status changed from new to closed
  • resolution set to fixed

This is fixed in r40313, which also adds a test case to make sure it keeps working. Thanks for reporting.

Note: See TracTickets for help on using tickets.