Skip to content

fix: Allow empty container's types to be lazily resolved - #443

Open
Ahajha wants to merge 3 commits into
withered-magic:mainfrom
Ahajha:trotta/fix-allow-empty-container-s-types-to-be-lazily-resolved
Open

Ahajha wants to merge 3 commits into
withered-magic:mainfrom
Ahajha:trotta/fix-allow-empty-container-s-types-to-be-lazily-resolved

Conversation

@Ahajha

@Ahajha Ahajha commented Oct 1, 2026 •

Copy link
Copy Markdown

Expressions such as [] + [1] would resolve to list[Unknown | int], which is a bit annoying. Worse, you could get warnings when doing even more logic on this, like passing to a rule which expects a list[int].

When constructing empty containers, we now use a separate placeholder EmptyUnspecified, which allows us to nicely merge with other ones.

This also handles dicts and tuples in similar ways, though they're a bit more compilated since there are multiple elements.

Fixes #386

Ahajha added 3 commits October 2, 2026 01:42
Expressions such as `[] + [1]` would resolve to `list[Unknown | int]`, which is a bit annoying. Worse, you could get warnings when doing even more logic on this, like passing to a rule which expects a `list[int]`.

When constructing empty containers, we now use a separate placeholder `EmptyUnspecified`, which allows us to nicely merge these types with other ones.

This also handles dicts and tuples in similar ways, though they're a bit more compilated since there are multiple elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Borrow type from left side of if expression for empty list

1 participant