When using a disjoint union and switching on the literal type, flow doesn't understand that some cases cannot happen. It could be nice to know that this is actually dead code. See this example . Or perhaps there's something I don't understand with disjoint unions?
@bhosmer has been working on generalized reachability, so I'm curious what he has to say here.
Yup, there's some reachability work in progress that would properly detect this. No definite ETA on landing it, unfortunately.
I'm looking forward to this because I've seen some bugs due to typos that this would have caught. How's progress, @bhosmer?
@bhosmer Any progress on this? Flow becomes truly valuable when it can report me that parts of my code are unreachable because of improper if statements and switch statements etc. It would save me lots of work debugging, especially when refactoring.
Seems like this was partially fixed in v0.58 when not all possible branches are covered.
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCqAdgJZzFgC8YA3mNvgFxgDkAhq2AL5gA+dBrjwtWAIy7d0AYwoBnDGGkALPNIDWAFWHUwACjww8AWzzEMLEuWIBKagD46qMHISkMK-YZNmMAOkY8O1pnMCV2OQIOViZQsLAAJzwMAFcEylYoUgSFVgBuOOkIqOkYuLCk1PS2DGVsgBN85ykpVBU1LWE9ekDRTh4bIA
However exhaustive switch do not error about additional cases
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCqAdgJZzFgC8YA3mNvgFxgDkAhq2AL5gA+dBrjwtWAIy7d0AYwoBnDGGkALPNIDWAFWHUwACjww8AWzzEMLEuWIBKagD46qMHISkMK-YZNmMAOkY8O1pnMCV2OQIOViZQsLAAJzwMAFcEylYoUgSFVgBuOOkIqIlY+LCk1PS2SNliABN8wuK2aRi4iuS0jIxlbMaCnlQpVBU1LWE9ekDRTh4bIA
Most helpful comment
Yup, there's some reachability work in progress that would properly detect this. No definite ETA on landing it, unfortunately.