ruff/crates/red_knot_python_semantic/resources/mdtest/conditional/match.md
Micha Reiser 6aaf1d9446
[red-knot] Remove lint-phase (#13922)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-25 18:40:52 +00:00

484 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

# revealed: Unbound | Literal[2, 3]
# error: [possibly-unresolved-reference]
reveal_type(y)

Basic match

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

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