Pyrefly does not eliminate conditional expression branches based on previous narrowing
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
```python
def f(x: int | None) -> None:
if x is not None:
y = 1 if x is not None else None # since we guard that x is not None, we could prune away the `else None` case in the ternary
assert_type(y, int)
```
Python: 3.12
### Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSImMYABGABT6I0ToAuNAPjQHK7owAlDQC0APl78YiADroaClrXws4NdLg58Bs%2BYv2kaAXhoBGJTRUQ1GrVJowocGJIFz9%2B1HGcAnNgH02UmIYelIAGhZ2QRBwkDIfaihSQjZcAFsoCgBiGgAFUkSwZJo0LDwVAGN%2BSABzAFcfVDYIfkI5XIBlGBcACzY2YjhEAHoRhKSU3B9akZh0EcxcSrgR6vQ6xubWhbppmlQAN1RoVGxYGnXNppb%2BGlxiW-Q4dvQyNl7%2BEUOYHzgd4w0GQgADMhFMACZgXIANq-HzTOAAXTk9XQEHSxGmbBgmBEmAgiUqLR%2BgIA5BBahpEmS5LYRIkAI71Qm4kQAaxgpBEqEqlXgahMZIA7qgfOhaegQABfOK8kkwABi0BgFDKOAIJHI0qAA
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.