Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't refine union type in tuple #6676

Closed
pranaygp opened this issue Aug 2, 2018 · 1 comment
Closed

[BUG] Can't refine union type in tuple #6676

pranaygp opened this issue Aug 2, 2018 · 1 comment

Comments

@pranaygp
Copy link

pranaygp commented Aug 2, 2018

Minimal repro:
https://flow.org/try/#0PTAEAEDMBsHsHcBQAXAngBwKagLIENUAjTAHgBUA+UAXlAG0A7AV2mgBpQyBdUAH3oCiAJyGwhHZqy6JomZKFQAuXAWIlmAW2JCqtRi3agAjNMQBjWAwDO8uphEcAlj1qpEjyKAAU9oQEpQAG9EUFAQel8nF0ERMQkDaVCLa1hZADo4AHMfETSNTCsrPEzMAPCAZQALWBYAE1AAOQB5MlBfMUQAXzboK2xg0PC7B1BnGnpJQ01tRNBkq1TMDNhsxzTkWAAxRwAPTFqvACY-MrAqmuh65tb2oS6gA

In the case of a union type for tuple (which, in the example above, I use to simulate a Maybe type), flow can't refine the type in the else branch even though we're guaranteed at that point that the shape of y is [null, number], yet it errors because it thinks it could be [Error, number].

Here's a very slight modification that causes the other branch to lose refinement:

https://flow.org/try/#0PTAEAEDMBsHsHcBQAXAngBwKagLIENUAjTAHgBUA+UAXlAG0A7AV2mgBpQyBdUAH3oCiAJyGwhHZqy6JomZKFQAuXAWIlmAW2JCqtRi3agAjNMQBjWAwDO8uphEcAlj1qpEjyKAAUjmtVqS0ACUoADeiKCgIPT24qDONIIiYhIG0pEW1rCyAHRwAOZesTkamFZWePmYIdEAygAWsCwAJqAAcgDyZKCxYogAvj3QVtjhkdF2DvEu9IGpWvbpoJlW2Zh5sIWOOciwAGKOAB6YzV4ATEE1YA1N0K2d3b1CA0A

@bradennapier
Copy link

bradennapier commented Aug 3, 2018

#1414 #6429 #6464 #6565 #6666 #4296 #6677 #6408

I didnt look at those but I have run into it countless times so I know there are lots of unanswered mentions of it dating back many months. Just wanted to connect them for referencing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants