Skip to content

Commit

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

[case testMatchCapturePatternFromAsyncFunctionReturningUnion-xfail]
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:
reveal_type(a) # N: Revealed type is "builtins.int"

-- Guards --

[case testMatchSimplePatternGuard]
Expand Down

0 comments on commit bb11db2

Please sign in to comment.