Typed array type alias problem
The following works:
<?hh // strict
type Test = array<int>;
f();
function f(array<int> $t = [1]): void
{
var_dump($t);
}
However, if you change the function definition, changing "array
"Default value for parameter t with type Array needs to have the same type as the type hint Test "
Both versions pass the type checker.
Hmm, looks like a bug here where we check the default value type at compile time. I don't see anything here dealing with the possibility of a type alias.
We've run into this with shapes as well in 3.15.0-dev (2016-08-25).
https://3v4l.org/gWW08
I am going over old issues on this repository, to see which ones apply to the current versions of hhvm.
It appears like this problem was fixed at some point, but I can't find the blogpost for it.
Your repro var_dump()'s array[1]{ [0] => int(1) }.
<<__EntryPoint>>
function main(): void {
f();
}
type Test = array<int>;
function f(Test $t = varray[1]): void {
var_dump($t);
}