Files
ruff/crates/red_knot_python_semantic/resources/mdtest/conditional/match.md
Alex d77480768d [red-knot] Port type inference tests to new test framework (#13719)
## Summary

Porting infer tests to new markdown tests framework.

Link to the corresponding issue: #13696

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2024-10-15 11:23:46 -07:00

444 B

Pattern matching

With wildcard

match 0:
    case 1:
        y = 2
    case _:
        y = 3

reveal_type(y)  # revealed: Literal[2, 3]

Without wildcard

match 0:
    case 1:
        y = 2
    case 2:
        y = 3

reveal_type(y)  # revealed: Unbound | Literal[2, 3]

Basic match

y = 1
y = 2
match 0:
    case 1:
        y = 3
    case 2:
        y = 4

reveal_type(y)  # revealed: Literal[2, 3, 4]