Skip to content

Assertion failure crash: assert not self.has_type_var_tuple_type #20287

Description

@correctmost

Crash Report

The snippet below crashes mypy 1.18.2 and the latest code from master (96fac3a).

Traceback

Traceback (most recent call last):
  File ".venv-mypy/bin/mypy", line 7, in <module>
    sys.exit(console_entry())
  File "mypy/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/mypy/main.py", line 127, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "mypy/mypy/main.py", line 211, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "mypy/mypy/build.py", line 215, in build
    result = _build(
  File "mypy/mypy/build.py", line 294, in _build
    graph = dispatch(sources, manager, stdout)
  File "mypy/mypy/build.py", line 2945, in dispatch
    process_graph(graph, manager)
  File "mypy/mypy/build.py", line 3336, in process_graph
    done, still_working = manager.wait_for_done(graph)
  File "mypy/mypy/build.py", line 918, in wait_for_done
    process_stale_scc(graph, next_scc, self)
  File "mypy/mypy/build.py", line 3468, in process_stale_scc
    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
  File "mypy/mypy/semanal_main.py", line 95, in semantic_analysis_for_scc
    process_top_levels(graph, scc, patches)
  File "mypy/mypy/semanal_main.py", line 233, in process_top_levels
    deferred, incomplete, progress = semantic_analyze_target(
  File "mypy/mypy/semanal_main.py", line 410, in semantic_analyze_target
    analyzer.refresh_partial(
  File "mypy/mypy/semanal.py", line 701, in refresh_partial
    self.refresh_top_level(node)
  File "mypy/mypy/semanal.py", line 719, in refresh_top_level
    self.accept(d)
  File "mypy/mypy/semanal.py", line 7563, in accept
    node.accept(self)
    ~~~~~~~~~~~^^^^^^
  File "mypy/mypy/nodes.py", line 1478, in accept
    return visitor.visit_class_def(self)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/semanal.py", line 1827, in visit_class_def
    self.analyze_class(defn)
    ~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/semanal.py", line 2021, in analyze_class
    self.setup_type_vars(defn, tvar_defs)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "mypy/mypy/semanal.py", line 2063, in setup_type_vars
    defn.info.add_type_vars()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "mypy/mypy/nodes.py", line 3611, in add_type_vars
    assert not self.has_type_var_tuple_type
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 

To Reproduce

class C[*T, *U]:
   pass

Your Environment

  • Mypy version used: 96fac3a (and 1.18.2)
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.13.7
  • Operating system and version: Arch Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions