Skip to content

Crash involving ParamSpec, Concatenate and overloads #12922

@AlexWaygood

Description

@AlexWaygood

Crash Report

The following snippet of code causes a mypy crash:

from typing import ParamSpec, TypeVar, Concatenate, Callable, overload

P = ParamSpec("P")
R = TypeVar("R")
S = TypeVar("S")

@overload
def bar(x: Callable[Concatenate[S, P], R]) -> str: ...
@overload
def bar(x: Callable[P, R]) -> int: ...
def bar(x: Callable[..., R]) -> str | int: ...

Discovered in python/typeshed#7771.

Mypy output

Traceback (most recent call last):
  File "/opt/python3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/python3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "mypy/checker.py", line 431, in accept
  File "mypy/nodes.py", line 581, in accept
  File "mypy/checker.py", line 464, in visit_overloaded_func_def
  File "mypy/checker.py", line 491, in _visit_overloaded_func_def
  File "mypy/checker.py", line 573, in check_overlapping_overloads
  File "mypy/checker.py", line 6118, in is_unsafe_overlapping_overload_signatures
  File "mypy/subtypes.py", line 982, in is_callable_compatible
  File "mypy/subtypes.py", line 1051, in are_parameters_compatible
  File "mypy/subtypes.py", line 1178, in are_args_compatible
  File "mypy/subtypes.py", line 1183, in new_is_compat
  File "mypy/checker.py", line 6603, in is_overlapping_types_no_promote
  File "mypy/meet.py", line 335, in is_overlapping_types
  File "mypy/subtypes.py", line 982, in is_callable_compatible
  File "mypy/subtypes.py", line 1039, in are_parameters_compatible
  File "mypy/subtypes.py", line 1037, in _incompatible
  File "mypy/meet.py", line 181, in _is_overlapping_types
  File "mypy/meet.py", line 401, in is_overlapping_types
AssertionError: 
main.py:7: 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: 0.960
main.py:7: : note: use --pdb to drop into pdb

Note that this is a very similar traceback to #12322, but I have no idea if it's the same issue, since #12322 doesn't have a minimal repro.

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.10&flags=show-traceback&gist=13ea15dacce1cac389fbd26c5fca569f

Your Environment

  • Mypy version used: 0.960
  • Python version used: 3.10

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions