Search code examples
hhvmhacklang

HHVM non-deterministic behaviour of the typechecker


I've noticed that calling hh_client is not always returning correct result. For example: I have following pieces of code:

backend\ConvertMessage.hh:

<?hh // strict

namespace ApiBackend\ConvertMessage {

    enum Status: int {
        success = 0;
        // ... error codes
    };

    // ... some other classes

};

other place in project:

throw new \SoapFault(
    'Server',
    \ApiBackend\ConvertMessage\Status::getNames()[$result->status]
);

Sometimes, after doing some changes in project I get following error message: Could not find static method getNames in type ApiBackend\ConvertMessage\Status (Typing[4090])

When I remove a semicolon after one of closing curly brackets, hh_client stops displaying error. But when I insert semicolon back on its place, typechecker still gives me No errors! message.

This is not the only file that causes this problem - it happens to all enums.

It seems to me that it is problem with some cache of either hh_client or hh_server.

Thanks in advance for helping me with solving this problem (and sorry if my english is not too good).


Solution

  • You are probably using an outdated version of HHVM. This problem sounds an awful lot like this race condition, which was fixed in HHVM 3.5.0 and newer (and was backported into the 3.3.3 LTS release). Notably, 3.4.x still had the bug.

    What version of HHVM are you using?