zephir icon indicating copy to clipboard operation
zephir copied to clipboard

Failure to call overloaded method when compiled with `internal-call-transformation: true`

Open andrewdalpino opened this issue 5 years ago • 5 comments

Greetings Phalcon/Zephir team,

The multiply, divide, add, subtract, greater, greater equal, less, and less equal tests starting here fail when the Tensor extension is compiled with "internal-call-transformation: true". They do not fail when the extension is compiled without the optimization.

It looks like what's happening is that the non-static child methods on ColumnVector that overload the parent's (Vector) methods are not being called. Instead the parent method is being called with the same method signature. This explains why the result is erroneous for multiplication, addition, etc. with a column vector (i.e. test fail) but is correct for a row vector.

andrewdalpino avatar Dec 04 '19 02:12 andrewdalpino

@dreamsxin Could you take a look by any chance?

sergeyklay avatar Dec 04 '19 05:12 sergeyklay

I will test it tomorrow

dreamsxin avatar Dec 04 '19 07:12 dreamsxin

@sergeyklay Vector.zep

    protected function multiplyMatrix(const <Matrix> b) -> <Matrix>
    {
        //...
    }
    public function multiply(const var b)
    {
        return this->multiplyVector(b);
    }

ColumnVector.zep

class ColumnVector extends Vector {
    protected function multiplyMatrix(const <Matrix> b) -> <Matrix>
    {
    }
}

In vector.zep.c the internal function name is fixed, can't overload.

ZEPHIR_RETURN_CALL_INTERNAL_METHOD_P1(this_ptr, zep_Tensor_Vector_multiplyMatrix_zephir_internal_call, b);

Zephir should stipulate that no inherited method can automatically become an internal function

dreamsxin avatar Dec 05 '19 09:12 dreamsxin

@andrewdalpino Hello, is this still and bug or it was fixed?

Jeckerson avatar Apr 05 '21 22:04 Jeckerson

@andrewdalpino Hello, is this still and bug or it was fixed?

Hey @Jeckerson, I can't remember hahah but it hasn't effected our development lately. I will say we no longer have an "internal-call-transformation: true" entry in our config.json. I do remember having to turn this optimization off specifically with previous versions.

andrewdalpino avatar Apr 05 '21 23:04 andrewdalpino