-
Notifications
You must be signed in to change notification settings - Fork 219
Description
Right now we infer a todo type, which suppresses false positives. But intersections arise reasonably frequently in narrowing, and often don't simplify (especially with negative or dynamic elements). So this can lead to a lot of false negatives.
The algorithm here isn't particularly hard. We should try to call each element of the intersection. We can probably short-circuit some cases (most negative intersection elements will simply fallback to object, and we know object is not callable). If calls to any element(s) succeed, the return type is the intersection of their returns, and we should ignore errors from those that failed. If all fail, we probably want to discard errors from some very general types (the same cases we considered short-circuiting above) and display the other errors. (Handling the diagnostics is probably the most complex piece of this issue.)
We could also do a very simple initial version here where we try to short-circuit negative elements and if that reduces the intersection to a single type, call it normally. That would already improve things a lot for narrowing cases.