Skip to content

Commit

Permalink
Add test documenting #12998
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Apr 30, 2024
1 parent ba6febc commit ccba491
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test-data/unit/check-python310.test
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,22 @@ def main() -> None:
case a:
reveal_type(a) # N: Revealed type is "builtins.int"

[case testMatchCapturePatternFromAsyncFunctionReturningUnion]
async def func1(arg: bool) -> str | int: ...
async def func2(arg: bool) -> bytes | int: ...

async def main() -> None:
match await func1(True):
case str(a):
match await func2(True):
case c:
reveal_type(a) # N: Revealed type is "builtins.str"
reveal_type(c) # N: Revealed type is "Union[builtins.bytes, builtins.int]"
reveal_type(a) # N: Revealed type is "builtins.str"
case a:
# TODO: this should be builtins.int!
reveal_type(a) # N: Revealed type is "Union[builtins.str, builtins.str, builtins.int]"

-- Guards --

[case testMatchSimplePatternGuard]
Expand Down

0 comments on commit ccba491

Please sign in to comment.