Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash involving ParamSpec, Concatenate and overloads #12922

Closed
AlexWaygood opened this issue Jun 1, 2022 · 0 comments · Fixed by #12953
Closed

Crash involving ParamSpec, Concatenate and overloads #12922

AlexWaygood opened this issue Jun 1, 2022 · 0 comments · Fixed by #12953
Labels
crash topic-overloads topic-paramspec PEP 612, ParamSpec, Concatenate

Comments

@AlexWaygood
Copy link
Member

AlexWaygood commented Jun 1, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash topic-overloads topic-paramspec PEP 612, ParamSpec, Concatenate
Projects
None yet
1 participant