Fix hack-dune failure
[hiphop-php.git] / hphp / hack / test / typecheck / typehole / T90668594.php
blobecce1a3445ca1bc91efaf37b850f7fe5c4c58088
1 <?hh
3 class :xhp {
4 attribute string attr;
6 public function __construct(
7 public darray<string,mixed> $attributes,
8 varray<mixed> $_,
9 string $_,
10 int $_,
11 ): void {}
13 public function getAttribute(string $attr, mixed $default = null): mixed {
14 $this->attributes['attr'] = 42;
16 return $this->attributes[$attr];
20 function takes_string(string $_): void {}
22 <<__EntryPoint>>
23 function oops(): void {
24 $xhp = <xhp attr="hi" />;
25 // Type refinement causes attribute to become an int
26 if ($xhp->:attr is nonnull) {
27 // The typechecker thinks the type of $xhp->attr is string
28 takes_string($xhp->:attr); // Fatals