facebook / facebook/pyrefly

Passing an empty list to `sum` results in an odd type being inferred for it

Open
#1,584 5 comments 1 reaction 1 assignee Claimed by @asukaminato0721 View on GitHub
typechecking
Dominant language
Rust
Stars
7k
Forks
519
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug
```
from typing import reveal_type
x = []
y = sum(x)
# revealed type: list[Literal[-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] | bool]
reveal_type(x)
```

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSI%2BABALxUDaAugDrqm1VwCuAtgBT4AlCAA0ILgBdocEuUQgAxFQCqUqBAnswXdAGMpudHFatMMMFTC4ATj1QSA%2Bul7YY1gYioR0EwVQC0AHycEtaIrFSRVNYwElzW6JbMIAByLm6ewPgAvsmsoiBkMWBQpIQSuDxQFEoACqTFpZwYOARUuoaQAObx9hCGhKxKAMowMFQAFhISxHCIAPTzRealhDZd8zDo85i4unDzHejdvQbbljZUqABuqNCo2LDtnRA91n2GVLjEZzKsZBIJoZ-Nc3HB%2Bok6MkAMyEACMACY8ugQNkxKh9BBQQAxaAwChoLB4IhkVFAA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.