Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/ty_python_semantic/resources/mdtest/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,20 @@ reveal_type(Toggle().x) # revealed: Literal[True]
reveal_type(Toggle().y) # revealed: Unknown | Literal[True]
```

Make sure that the growing union of literals `Literal[0, 1, 2, ...]` collapses to `int` during
fixpoint iteration. This is a regression test for <https://github.com/astral-sh/ty/issues/660>.

```py
class Counter:
def __init__(self: "Counter"):
self.count = 0

def increment(self: "Counter"):
self.count = self.count + 1

reveal_type(Counter().count) # revealed: Unknown | int
```

### Builtin types attributes

This test can probably be removed eventually, but we currently include it because we do not yet
Expand Down
5 changes: 4 additions & 1 deletion crates/ty_python_semantic/src/types/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ enum ReduceResult<'db> {

// TODO increase this once we extend `UnionElement` throughout all union/intersection
// representations, so that we can make large unions of literals fast in all operations.
const MAX_UNION_LITERALS: usize = 200;
//
// For now (until we solve https://github.com/astral-sh/ty/issues/957), keep this number
// below 200, which is the salsa fixpoint iteration limit.
const MAX_UNION_LITERALS: usize = 199;

pub(crate) struct UnionBuilder<'db> {
elements: Vec<UnionElement<'db>>,
Expand Down
Loading