Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method context loses track of 'this' after calling static method and compiled with "internal-call-transformation": true #2007

Closed
andrewdalpino opened this issue Nov 12, 2019 · 1 comment

Comments

@andrewdalpino
Copy link

@andrewdalpino andrewdalpino commented Nov 12, 2019

The following block of code (source) results in the unintended side effect of losing reference to 'this' after the static method call ...

    public function reciprocal() -> <Matrix>
    {
        var_dump(this);

        var ones = self::ones(this->m, this->n);

        var_dump(this);

        ...
    }

Output

 ["a":protected]=>
  array(3) {
    [0]=>
    array(3) {
      [0]=>
      int(22)
      [1]=>
      int(-17)
      [2]=>
      int(12)
    }
    [1]=>
    array(3) {
      [0]=>
      int(4)
      [1]=>
      int(11)
      [2]=>
      int(-2)
    }
    [2]=>
    array(3) {
      [0]=>
      int(20)
      [1]=>
      int(-6)
      [2]=>
      int(-9)
    }
  }
  ["m":protected]=>
  int(3)
  ["n":protected]=>
  int(3)
}

NULL

... when running this test and the extension is compiled with the internal-call-transform optimization. Notice this is null after the static method call.

Assigning 'this' to a temporary variable before calling the static method can be used as a workaround ...

var temp = this;

To me, this means that somehow 'this' is being sent into oblivion after a static method call from a method context, but you'll know more about whats going on under the hood. This particular phenomena is the cause of 2 separate errors in the test suite. I'm assuming it's unexpected behavior since it works fine when compiled with "internal-call-transformation:" false.

@dreamsxin dreamsxin mentioned this issue Nov 14, 2019
1 of 3 tasks complete
@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Nov 21, 2019

Fixed in the development branch. Feel free to open a new issue if the problem appears again. Thank you for the bug report.

@sergeyklay sergeyklay closed this Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.