facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.16k stars 2.99k forks source link

Shapes can't be recursively defined, even when it makes sense #5594

Open steelbrain opened 9 years ago

steelbrain commented 9 years ago
<?hh //strict
type a = shape(
  'name' => string,
  'min' => int,
  'max' => int,
  'type' => string,
  'validate' => (function(a):void) // Error: Cyclic typedef (Typing[4014])
);
milesj commented 9 years ago

This seems like it should be a class.

jwatzman commented 9 years ago

Yeah, it's a current limitation of shapes that they can't be recursively defined in any way. Another possibility where this could be useful is

type a = shape(
 'foo' => ?a,
  // ...
);