Skip to content

Internal error when specialization for TypeVarTuple contains multiple unpacked tuples #18856

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

Closed
erictraut opened this issue Mar 30, 2025 · 0 comments · Fixed by #18857
Closed
Labels
bug mypy got something wrong crash topic-pep-646 PEP 646 (TypeVarTuple, Unpack)

Comments

@erictraut
Copy link

The following code results in a mypy "INTERNAL ERROR".

class A[*Ts]: ...

A[*tuple[int, ...], *tuple[int, ...]]  # no error, fails at runtime:
# TypeError: More than one unpacked arbitrary-length tuple argument

b: tuple[*tuple[int, ...], *tuple[int, ...]]  # error, as expected

Here's the stack trace for the crash:

version: 1.15.0
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 5903, in accept
  File "mypy/nodes.py", line 2488, in accept
  File "mypy/checkexpr.py", line 4768, in visit_type_application
  File "mypy/checkexpr.py", line 4963, in apply_type_arguments_to_callable
  File "mypy/checkexpr.py", line 4899, in split_for_callable
  File "mypy/typeanal.py", line 2532, in validate_instance
  File "mypy/types.py", line 3732, in find_unpack_in_list
AssertionError: 

I found this when diagnosing a bug reported against pyright.

It may be related to #17755.

@erictraut erictraut added the bug mypy got something wrong label Mar 30, 2025
@ilevkivskyi ilevkivskyi added crash topic-pep-646 PEP 646 (TypeVarTuple, Unpack) labels Mar 30, 2025
ilevkivskyi added a commit that referenced this issue Mar 31, 2025
Fixes #18856. This should be done by `TypeAnalyzer.anal_array` but is
not - semanal only invokes its own wrapper around `anal_type`

---------

Co-authored-by: Ivan Levkivskyi <[email protected]>
jhance pushed a commit that referenced this issue May 12, 2025
Fixes #18856. This should be done by `TypeAnalyzer.anal_array` but is
not - semanal only invokes its own wrapper around `anal_type`

---------

Co-authored-by: Ivan Levkivskyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong crash topic-pep-646 PEP 646 (TypeVarTuple, Unpack)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants