Skip to content

Assertion failure crash in split_for_callable: assert t.is_type_obj() #20542

@correctmost

Description

@correctmost

Crash Report

The snippet below crashes mypy 1.19.1 and master (8eb14fb).

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 135, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "mypy/mypy/main.py", line 219, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "mypy/mypy/build.py", line 320, in build
    result = build_inner(
  File "mypy/mypy/build.py", line 417, in build_inner
    graph = dispatch(sources, manager, stdout)
  File "mypy/mypy/build.py", line 3178, in dispatch
    process_graph(graph, manager)
  File "mypy/mypy/build.py", line 3588, in process_graph
    done, still_working, results = manager.wait_for_done(graph)
  File "mypy/mypy/build.py", line 1070, in wait_for_done
    process_stale_scc(graph, next_scc, self)
  File "mypy/mypy/build.py", line 3752, in process_stale_scc
    graph[id].type_check_first_pass()
  File "mypy/mypy/build.py", line 2543, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "mypy/mypy/checker.py", line 530, in check_first_pass
    self.accept(d)
  File "mypy/mypy/checker.py", line 641, in accept
    stmt.accept(self)
  File "mypy/mypy/nodes.py", line 1602, in accept
    return visitor.visit_expression_stmt(self)
  File "mypy/mypy/checker.py", line 4898, in visit_expression_stmt
    expr_type = self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
  File "mypy/mypy/checkexpr.py", line 6083, in accept
    typ = node.accept(self)  # r-value type, when interpreted as a value expression
  File "mypy/mypy/nodes.py", line 2362, in accept
    return visitor.visit_index_expr(self)
  File "mypy/mypy/checkexpr.py", line 4389, in visit_index_expr
    result = self.visit_index_expr_helper(e)
  File "mypy/mypy/checkexpr.py", line 4403, in visit_index_expr_helper
    return self.accept(e.analyzed)
  File "mypy/mypy/checkexpr.py", line 6083, in accept
    typ = node.accept(self)  # r-value type, when interpreted as a value expression
  File "mypy/mypy/nodes.py", line 2856, in accept
    return visitor.visit_type_application(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/checkexpr.py", line 4845, in visit_type_application
    return self.apply_type_arguments_to_callable(tp, tapp.types, tapp)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "mypy/mypy/checkexpr.py", line 5040, in apply_type_arguments_to_callable
    return self.apply_generic_arguments(tp, self.split_for_callable(tp, args, ctx), ctx)
                                            ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "mypy/mypy/checkexpr.py", line 4969, in split_for_callable
    assert t.is_type_obj()
           ~~~~~~~~~~~~~^^
AssertionError: 

To Reproduce

def fn[*T]() -> T:
    pass

fn[1]

Your Environment

  • Mypy version used: 8eb14fb (and 1.19.1)
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.13.11
  • 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