Skip to content

Instantly share code, notes, and snippets.

@jazzdan
Forked from anonymous/main.hh
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jazzdan/26d64882fab4a3d95c1e to your computer and use it in GitHub Desktop.
Save jazzdan/26d64882fab4a3d95c1e to your computer and use it in GitHub Desktop.
<?hh
class Wrapper<Tval as num> {
private Tval $value;
public function __construct(Tval $value) {
$this->value = $value;
}
public function setValue(Tval $value): void {
$this->value = $value;
}
public function getValue(): Tval {
return $this->value;
}
public function add(num $addend): void {
$this->value += $addend;
}
}
@jazzdan
Copy link
Author

jazzdan commented Jul 13, 2015

Output:

$ hh_client main.hh
main.hh:17:5,27: Invalid assignment (Typing[4110])
  main.hh:3:15,18: This is a value of generic type Tval
  main.hh:4:11,14:   via this generic Tval
  main.hh:16:23,25: It is incompatible with a num (int/float)

HHVM version:

$ hhvm --version
HipHop VM 3.8.0-dev (rel)
Compiler: heads/master-0-g1100e471847b144850917aea3fda0dba4b86d99b
Repo schema: 9ffd6c11e5c199737209a7d4ee4e10a25fbc3f94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment