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

"INTERNAL ERROR: maximum semantic analysis iteration count reached" using NamedTuple #16814

Closed
clo-vis opened this issue Jan 24, 2024 · 1 comment · Fixed by #17498
Closed

Comments

@clo-vis
Copy link

clo-vis commented Jan 24, 2024

To Reproduce

from typing import NamedTuple

def bar() -> None:
    class MyNamedTuple(NamedTuple):
        a: int

        def foo(self) -> None:
            print(self.a, misspelled_var_name)

Expected Behavior
The error Name "misspelled_var_name" is not defined.

Actual Behavior

Deferral trace:
    src.foo:8
    src.foo:8
...
    src.foo:8
src\foo.py: error: INTERNAL ERROR: maximum semantic analysis iteration count reached

Your Environment

  • Mypy version used: 1.8.0 (compiled: yes)
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.11.6
@clo-vis clo-vis added the bug mypy got something wrong label Jan 24, 2024
@AlexWaygood AlexWaygood added crash topic-named-tuple and removed bug mypy got something wrong labels Jan 24, 2024
@clo-vis
Copy link
Author

clo-vis commented Jan 24, 2024

A similar example, where I'd expect the error Name "Set" is not defined but also get INTERNAL ERROR:

from typing import NamedTuple

def bar() -> None:
    class MyNamedTuple(NamedTuple):
        a: int

        def foo(self) -> None:
            ...

    int_set: Set[int] = { 1 }

(The "deferral trace" for this example is longer.)

ilevkivskyi added a commit that referenced this issue Jul 6, 2024
Fixes #16814

This one is tricky and may expose some other bugs. But IMO this is
strictly correct thing to do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants