Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flow] consider RArrayPatternRestProp fresh
Summary: Before this diff, ``` declare var arr : [number]; [...arr] = [1 as 1]; ``` was an error. The reason has to do with the type we would infer for an array type emerging from the rest operation. This type was checked against the defined type of `arr`. The former type was an array type with `1` as its element, and `RArrayPatternRestProp` as the reason on the array. `RArrayPatternRestProp` is not a "literal" reason, meaning that it will not short-circuit an Array-to-Array check to a co-variant check on their element types. The invariant check the follows would cause an error on the side of `number <: 1`. This diff fixes this by treating the inferred type as a freshly generated array literal, which is consistent with other source of array literal freshness. Specifically, it does so by considering the relevant reason `RArrayPatternRestProp` a literal reason. Changelog: [fix] fixed a bug that caused spurious errors on rest array assignments (e.g. [try-Flow](https://flow.org/try/#1N4Igxg9gdgZglgcxALlAIwIZoKYBsD6uEEAztvhgE6UYCe+JADpdhgCYowa5kA0I2KAFcAtiRQAXSkOz9sADwxgJ+NPTbYuQ3BMnTZA+Y2yU4IwRO4A6SFBIrGVDGM7c+h46fNRLuKxJIGWh8MeT0ZfhYlCStpHzNsFBAMIQkIEQwJODAQfiEyfBE4eWw2fDgofDBMsAALfAA3KjgsXGxxZC4eAw0G-GhcWn9aY3wWZldu-g1mbGqJUoBaCRHEzrcDEgBrbAk62kXhXFxJ923d-cPRHEpTgyEoMDaqZdW7vKgoOfaSKgOKpqmDA+d4gB5fMA-P6LCCMLLQbiLOoYCqgh6-GDYRYIXYLSgkRZkCR4jpddwPfJLZjpOBkO4AX34kA0SQ0Tyo2AABIDOVRKMhOQBtYQiG4AH3spigCAAugBuAA6UEFVlVfJlnIAvEKAIzyzkAegNnIA7nBjpyoBAJJycLyoJyTJQIJR7bROSIXdglbkQA0TCQ4NAkg0AAxWABMADYdZGQPSgA)). Reviewed By: SamChou19815 Differential Revision: D69941196 fbshipit-source-id: 0fc9ca8e2bb5c0d30c4e3c1a29372fd5961b2337
- Loading branch information