-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix checking of match sequence pattern against bounded type variables (…
…#18091) Fixes #18089 Adds handling for bounded type variables when checking match sequence patterns. Previously, this crashed. Now, this correctly narrows the upper bound of the type variable: ```python from typing import TypeVar, Sequence T = TypeVar("T", bound=Sequence[int | str]) def accept_seq_int(x: Sequence[int]): pass def f(x: T) -> None: match x: case [1, 2]: accept_seq_int(x) # ok: upper bound narrowed to Sequence[int] case _: accept_seq_int(x) # E: Argument 1 to "accept_seq_int" has incompatible type "T"; expected "Sequence[int]" ```
- Loading branch information
1 parent
fa01a07
commit 880eb87
Showing
2 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters