Andrew Whitworth via RT wrote:
With some help from DietCoke, we got most of the problem solved.
However, several tests are failing now, especially those dealing with
overriding the invoke vtable method.
One error specifically caught my eye, from t/pmc/namespace.t:1672:
sub 'main' :main
$P0 = newclass 'Override'
$P1 = new 'Override'
$P2 = find_method $P1, 'foo'
end
namespace [ 'Override' ]
sub 'find_method' :vtable
say "Finding method"
end
With the patch, this test returns an error that we are passing one
parameter, but expecting 0. This is, I assume, desired behavior: We are
passing one parameter (the method name string 'foo'), but 'find_method'
isn't expecting any parameters. Changing the method to this fixes the
problem:
sub 'find_method' :vtable
.param string name
say "Finding method"
end
I suspect this is desired behavior, because the 'find_method' vtable
method should take the name of the method to find as a parameter
(otherwise, how do you know what to find?)
Yes, this is the expected behavior, the 'find_method' vtable override
should always take one parameter. (I'm assuming that some other test
checks that the 'self' parameter is available and correctly refers to
the invocant (the object that was $P1 in the find_method opcode).
Some of the other tests deal with object invoking, such as "$P0()". With
the patch, many of these tests are failing because we aren't passing
enough parameters. For instance, the following test is failing because
we are passing 0 parameters, when it expects 1:
namespace ['Foo']
sub invoke :vtable
say "you invoked me!"
.return()
end
sub main :main
$P0 = newclass "Foo"
$P1 = new "Foo"
$P1()
say "got here"
end
Changing the invocation to say "$P1($P1)" solves the error, but I doubt
this is desired. The parser is, I assume, trying to suck the object into
the self parameter, but it isn't being passed in the first place. On
invokes, we should be passing the object itself as a "self" parameter,
although I don't know how to make that happen.
Yes, the invoked sub object should be the invocant (the "self"
parameter) when the overridden vtable function is 'invoke'.
Likely you're looking for 'expand_pcc_sub_call' in compilers/imcc/pcc.c.
There's some code around lines 673 and 715 that looks like it's intended
to address this problem, but it may need to be fixed after your changes
(or after some previous changes to PMCs or objects).
Allison