Skip to content

Crash in match-statement's subject expression with an unpacked tuple #21468

@bastimeyer

Description

@bastimeyer

Crash Report

mypy crashes when it attempts to parse a match-statement with a subject expression that consists of a tuple with an unpacked secondary tuple inside.

See the mypy playground link:
https://mypy-play.net/?mypy=latest&python=3.14&flags=show-traceback&gist=e9fee1e1ecabfc2fc0aa5fc7a326f24c

foo = 0
bar = (1, 2)
match foo, *bar:
    case _:
        pass
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "mypy/checker.py", line 765, in accept
  File "mypy/nodes.py", line 2209, in accept
  File "mypy/checker.py", line 5968, in visit_match_stmt
  File "mypy/checker.py", line 6036, in _get_recursive_sub_patterns_map
AssertionError

main.py:3: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 2.0.0
main.py:3: note: use --pdb to drop into pdb

Your Environment

  • Mypy versions used: 1.20.2, 2.0.0, 2.1.0
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.14.4
  • Operating system and version: Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions