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 on dataclass nested in function #8703

Closed
Phlogistique opened this issue Apr 21, 2020 · 3 comments · Fixed by #12793
Closed

Internal error on dataclass nested in function #8703

Phlogistique opened this issue Apr 21, 2020 · 3 comments · Fixed by #12793
Labels
crash semantic-analyzer Problems that happen during semantic analysis topic-dataclasses

Comments

@Phlogistique
Copy link
Contributor

Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request?

Reporting a bug

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
from typing import List, Union
from dataclasses import dataclass, field


def foo():
    @dataclass
    class Foo:
        foo: int

        def __call__(self) -> asdf:
            ...
  • What is the actual behavior/output?
noes-MBP:mypy noe$ mypy ~/test.py --show-traceback
Deferral trace:
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
    test:10
/Users/noe/test.py: error: INTERNAL ERROR: maximum semantic analysis iteration count reached
/Users/noe/test.py: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.770+dev.69eb6fe8a8d7d091e2902b490ad6b43e6fed3d41
Traceback (most recent call last):
  File "/Users/noe/.pyenv/versions/mypy/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/__main__.py", line 8, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/main.py", line 89, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/build.py", line 181, in build
    sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/build.py", line 252, in _build
    graph = dispatch(sources, manager, stdout)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/build.py", line 2626, in dispatch
    process_graph(graph, manager)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/build.py", line 2949, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/build.py", line 3041, in process_stale_scc
    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_main.py", line 84, in semantic_analysis_for_scc
    check_type_arguments(graph, scc, errors)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_main.py", line 360, in check_type_arguments
    state.tree.accept(analyzer)
  File "/Users/noe/.pyenv/versions/3.7.3/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/build.py", line 1919, in wrap_context
    yield
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_main.py", line 360, in check_type_arguments
    state.tree.accept(analyzer)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/nodes.py", line 294, in accept
    return visitor.visit_mypy_file(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_typeargs.py", line 39, in visit_mypy_file
    super().visit_mypy_file(o)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/traverser.py", line 35, in visit_mypy_file
    d.accept(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/nodes.py", line 676, in accept
    return visitor.visit_func_def(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/traverser.py", line 54, in visit_func_def
    self.visit_func(o)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_typeargs.py", line 46, in visit_func
    super().visit_func(defn)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/mixedtraverser.py", line 22, in visit_func
    super().visit_func(o)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/traverser.py", line 51, in visit_func
    o.body.accept(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/nodes.py", line 1004, in accept
    return visitor.visit_block(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_typeargs.py", line 54, in visit_block
    super().visit_block(o)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/traverser.py", line 39, in visit_block
    s.accept(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/nodes.py", line 939, in accept
    return visitor.visit_class_def(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_typeargs.py", line 50, in visit_class_def
    super().visit_class_def(defn)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/mixedtraverser.py", line 28, in visit_class_def
    super().visit_class_def(o)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/traverser.py", line 71, in visit_class_def
    o.defs.accept(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/nodes.py", line 1004, in accept
    return visitor.visit_block(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_typeargs.py", line 54, in visit_block
    super().visit_block(o)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/traverser.py", line 39, in visit_block
    s.accept(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/nodes.py", line 676, in accept
    return visitor.visit_func_def(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/traverser.py", line 54, in visit_func_def
    self.visit_func(o)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_typeargs.py", line 46, in visit_func
    super().visit_func(defn)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/mixedtraverser.py", line 23, in visit_func
    self.visit_optional_type(o.type)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/mixedtraverser.py", line 91, in visit_optional_type
    t.accept(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/types.py", line 1098, in accept
    return visitor.visit_callable_type(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/typetraverser.py", line 52, in visit_callable_type
    t.fallback.accept(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/types.py", line 794, in accept
    return visitor.visit_instance(self)
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/semanal_typeargs.py", line 70, in visit_instance
    for (i, arg), tvar in zip(enumerate(t.args), info.defn.type_vars):
  File "/Users/noe/.pyenv/versions/3.7.3/envs/mypy/lib/python3.7/site-packages/mypy/nodes.py", line 2659, in __getattribute__
    raise AssertionError(object.__getattribute__(self, 'msg'))
AssertionError: fallback can't be filled out until semanal
/Users/noe/test.py: : note: use --pdb to drop into pdb
  • What is the behavior/output you expect?
/Users/noe/test.py:10: error: Name 'asdf' is not defined
  • What are the versions of mypy and Python you are using? Do you see the same issue after installing mypy from Git master?

Reproduced with 0.750 and master (69eb6fe8a8d7d091e2902b490ad6b43e6fed3d41) under Python 3.7.

  • What are the mypy flags you are using? (For example --strict-optional)

No flags

@msullivan msullivan added crash semantic-analyzer Problems that happen during semantic analysis labels Apr 29, 2020
@msullivan
Copy link
Collaborator

That's kind of nasty

@AlexWaygood
Copy link
Member

This crash was hit by another user in #11645

@AlexWaygood
Copy link
Member

Happily, this has been fixed by #12762, but we should add a test case. I've filed #12793

JukkaL pushed a commit that referenced this issue May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash semantic-analyzer Problems that happen during semantic analysis topic-dataclasses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants