Skip to content

Instantly share code, notes, and snippets.

@pbl64k
Created January 15, 2016 15:41
Show Gist options
  • Save pbl64k/adbf1c035e21efc6a4d2 to your computer and use it in GitHub Desktop.
Save pbl64k/adbf1c035e21efc6a4d2 to your computer and use it in GitHub Desktop.
Hack typechecker disagrees with run-time re at() signature in ConstIndexAccess
<?hh // strict
final class Dummy<Tx> implements ConstIndexAccess<int, Tx>
{
final public function __construct(private Tx $x) { }
final public function at(int $ix): Tx
{
return $this->x;
}
final public function get(int $ix): ?Tx
{
return $this->at($ix);
}
final public function containsKey<Tu super int>(Tu $ix): bool
{
return true;
}
}
<?hh // partial
require_once(__DIR__.'/Dummy.hh');
$d = new Dummy(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment