From ccba4914d9413e82697e835a511a2150e18a8593 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 30 Apr 2024 11:36:46 -0400 Subject: [PATCH] Add test documenting #12998 --- test-data/unit/check-python310.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test index 2b56d2db07a9c..a0e996c06684c 100644 --- a/test-data/unit/check-python310.test +++ b/test-data/unit/check-python310.test @@ -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]