Allow arbitrary splat destructuring for dynamicnightly-2022.04.06
commit38eb949e9a109a42a9c45ce89b449344754e1308
authorVassil Mladenov <[email protected]>
Wed, 6 Apr 2022 01:59:41 +0000 (5 18:59 -0700)
committerFacebook GitHub Bot <[email protected]>
Wed, 6 Apr 2022 01:59:41 +0000 (5 18:59 -0700)
treec1a9109e413e8f33a506be2ed6feb9b5f28af876
parent25c9b376e0a28cc021c36805af13d44c5a599d72
Allow arbitrary splat destructuring for dynamic

Summary:
I made a choice when writing Tdestructure that `dynamic` should splat like a vec, meaning that the function is required to have a variadic parameter to accept an arbitrary length array.

However, now that we are actively replacing parameter types with dynamic, a tuple can become dynamic and then a previously correct splat will fail on the dynamic pass. This changes dynamic to splat like a tuple under sound dynamic.
```
function f(~arraykey $i, ~arraykey $s): void {}

f(...tuple(1,"a")); // ok
f(...vec[1,"a"]); // bad
f(...$dynamic); // bad => ok
```

Reviewed By: francesco-zappa-nardelli

Differential Revision: D35407749

fbshipit-source-id: e5f31760ead511aed3c4e27ae0ec0a1e03ee5abf
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/sound_dynamic/typing/splat_dynamic_finite.good.php [new file with mode: 0644]
hphp/hack/test/sound_dynamic/typing/splat_dynamic_finite.good.php.exp [new file with mode: 0644]