From 3579c6149b74bee4717fb5fcac9e4351d36fe1b5 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 20 May 2024 22:33:13 -0400 Subject: [PATCH] Add test documenting #17230 (#17199) --- test-data/unit/check-python310.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test index 2b56d2db07a9..8991b65f67b5 100644 --- a/test-data/unit/check-python310.test +++ b/test-data/unit/check-python310.test @@ -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]