Skip to content

Incorrect number of type arguments causes internal error #996

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
bcdarwin opened this issue Nov 24, 2015 · 5 comments
Closed

Incorrect number of type arguments causes internal error #996

bcdarwin opened this issue Nov 24, 2015 · 5 comments
Labels
bug mypy got something wrong

Comments

@bcdarwin
Copy link

from typing import TypeVar

T = TypeVar('T')

class C(object):  # forgot to add type params here
    def __init__(self, t : T) -> None:
        self.t   = t

c = C(t = 3)  # type: C[int]  # this will crash

causes:

Traceback (most recent call last):
    ...
    cb = infer_constraints(mapped.args[i], instance.args[i],
IndexError: list index out of range

I guess this generalizes #981 and provides an additional example, here with an (accidentally) non-generic type (though the same happens if too few type arguments are supplied). I'm not sure if it overlaps with #300.

@bcdarwin bcdarwin changed the title Applying a type declared with no parameters causes internal error Incorrect number of type parameters causes internal error Nov 24, 2015
@bcdarwin bcdarwin changed the title Incorrect number of type parameters causes internal error Incorrect number of type arguments causes internal error Nov 24, 2015
@gvanrossum
Copy link
Member

Hm... I'm seeing IndexError too, in a slightly different context (#991). Which version of mypy did you use? (The one from PyPI is way out of date -- #991 is with the current development HEAD.)

@refi64
Copy link
Contributor

refi64 commented Nov 24, 2015

I think I found the issue! Hold on...

@bcdarwin
Copy link
Author

It's a recent install from master, though I don't know how to (easily) find the commit.

refi64 added a commit to refi64/mypy that referenced this issue Nov 24, 2015
@JukkaL JukkaL added the bug mypy got something wrong label Nov 24, 2015
@JukkaL
Copy link
Collaborator

JukkaL commented Nov 24, 2015

I was able to repro this. Thanks for reporting the bug!

@refi64
Copy link
Contributor

refi64 commented Nov 24, 2015

@JukkaL I fixed it already!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

4 participants