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

Flow does not catch invalid switch statements #9104

Open
ayroblu opened this issue Nov 5, 2023 · 1 comment
Open

Flow does not catch invalid switch statements #9104

ayroblu opened this issue Nov 5, 2023 · 1 comment

Comments

@ayroblu
Copy link

ayroblu commented Nov 5, 2023

Posting here, cause this caused a production incident at our company. For the most part we're "fine" with our usage of flow, but this is one of the more serious bugs

Flow version:
0.220.1

Expected behavior

Incorrect switch case statements should throw an error

Actual behavior

Switch case statements are allowed to do anything

  • Link to Try-Flow or Github repo: link

Specifically see this part:
image
Note the usage of "random_access"

@gkz
Copy link
Member

gkz commented Nov 6, 2023

Thanks for the report. For now, if using the disjoint object union pattern, stick to using literal types 'foo' directly rather than using typeof X.Foo, both when defining the type and when refining it (e.g. in a switch).

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

2 participants