How should pyrefly handle unions inside intersections?
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
A gap in our current implementation of intersections is that if we see a union inside an intersection, we simply give up on creating the intersection: https://github.com/facebook/pyrefly/blob/03131fd1c7fea035d07a219d00c26ac793efd27b/crates/pyrefly_types/src/simplify.rs#L98-L104
We should figure out a more principled way of handling this. An obvious solution is to immediately normalize the type, but that's potentially complicated and expensive.
Note that, in practice, this currently isn't a problem because we distribute over unions first in the only place where we create intersections: https://github.com/facebook/pyrefly/blob/03131fd1c7fea035d07a219d00c26ac793efd27b/pyrefly/lib/alt/narrow.rs#L131
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.