Skip to content

Crash type-checking overloaded function #15060

Closed
@evhub

Description

@evhub

Crash Report

Crash typing code that previously on older mypy versions worked fine. Not sure exactly how old the last working mypy version is for this, though (I think the release that broke this would have had to have been some time around January 2023).

Traceback

fmap_mypy_test.py:46: 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: 1.2.0
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "mypy\checkexpr.py", line 4885, in accept
  File "mypy\nodes.py", line 2032, in accept
  File "mypy\checkexpr.py", line 2917, in visit_op_expr
  File "mypy\checkexpr.py", line 3486, in check_op
  File "mypy\checkexpr.py", line 3408, in check_op_reversible
  File "mypy\checkexpr.py", line 3267, in check_method_call
  File "mypy\checkexpr.py", line 1303, in check_call
  File "mypy\checkexpr.py", line 2252, in check_overload_call
  File "mypy\checkexpr.py", line 2406, in infer_overload_return_type
  File "mypy\checkexpr.py", line 1292, in check_call
  File "mypy\checkexpr.py", line 1432, in check_callable_call
  File "mypy\expandtype.py", line 148, in freshen_function_type_vars
  File "mypy\expandtype.py", line 77, in expand_type
  File "mypy\types.py", line 1869, in accept
  File "mypy\expandtype.py", line 418, in visit_callable_type
  File "mypy\types.py", line 1357, in accept
  File "mypy\expandtype.py", line 230, in visit_instance
  File "mypy\expandtype.py", line 458, in expand_types_with_unpack
  File "mypy\types.py", line 2656, in accept
  File "mypy\expandtype.py", line 484, in visit_union_type
  File "mypy\expandtype.py", line 516, in expand_types
  File "mypy\types.py", line 1206, in accept
  File "mypy\expandtype.py", line 221, in visit_erased_type
RuntimeError:
fmap_mypy_test.py:46: : note: use --pdb to drop into pdb

To Reproduce

I was able to isolate the error down to just a relatively small code snippet. Just run mypy on https://gist.github.com/evhub/10d62ee526dddb9c9b27ad8c4632e32d to reproduce. Lines marked "OFFENDING LINES" are the ones that seem to be causing the error.

Your Environment

  • Mypy version used: 1.2.0
  • Mypy command-line flags: just --show-traceback
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.9.7
  • Operating system and version: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions