[BugReport] Automatic dict to shape coercion doesn't work inside of a KeyedContainer spec.
lexidor opened this issue · 2 comments
lexidor commented
Expected behavior
$shape_typespec->assertType(dict['a' => 0]); // shape('a' => 0)
Actual behavior
$with_kc = TypeSpec\of<KeyedContainer<arraykey, shape('a' => int)>>();
$with_vec = TypeSpec\of<vec<shape('a' => int)>>();
$data = vec[dict['a' => 0]];
$with_kc->assertType($data)[0] is shape(...); // false
$with_vec->assertType($data)[0] is shape(...); // true
skishore commented
I believe the same issue happens with Traversable and KeyedTraversable.
lexidor commented
Welcome to hhvm 4.103+, where shapes and tuples are Hack arrays and TypeAssert can stop casting hadva-ness. 🙂