Ticket #185 (closed bug: fixed)
thawed subs with :vtable don't register properly for existing classes
Reported by: | jhorwitz | Owned by: | jhorwitz |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | core | Version: | |
Severity: | medium | Keywords: | |
Cc: | Language: | ||
Patch status: | Platform: |
Description (last modified by jhorwitz) (diff)
If a class is created before load_bytecode thaws a :vtable sub for that class, parrot tries to override a vtable method with the same name as the thawed sub. This blows up when the sub name is not a valid vtable function, which is common in Rakudo. Everything works in fine in pure PIR.
At first glance, the culprit appears to be add_vtable_override() in src/pmc/class.pmc, which only uses the sub's name to check if it's a valid override. Shouldn't it also check the thawed sub's vtable_index?
This breaks mod_perl6, as mod_parrot needs to load P6object before loading Rakudo's perl6.pbc.
Test case follows.
bar.pir:
.sub '__onload' :load $P0 = newclass ['Bar'] .end
foo.pir:
.sub '__onload' :load load_bytecode 'bar.pbc' .end .namespace ['Bar'] .sub 'invalidname' :vtable('get_string') :method $S0 = 'hello world' .return($S0) .end
baz.pir:
.sub main :main load_bytecode 'bar.pbc' load_bytecode 'foo.pbc' .end
Output:
[jeff@groovy parrot]$ ./parrot -o foo.pbc foo.pir [jeff@groovy parrot]$ ./parrot -o bar.pbc bar.pir [jeff@groovy parrot]$ ./parrot baz1.pir 'invalidname' is not a valid vtable function name. current instr.: 'main' pc 2 (baz1.pir:3)