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 when checking for method override #2372

Closed
ddfisher opened this issue Oct 28, 2016 · 0 comments
Closed

Crash when checking for method override #2372

ddfisher opened this issue Oct 28, 2016 · 0 comments

Comments

@ddfisher
Copy link
Collaborator

class A:
    def f(self):
        # type: () -> str
        return 'foo'

class B(A):
    def f(self):
        # type: () -> str
        return self.x

    def initialize(self):
        # type: () -> None
        self.x = 'bar'

crashes with

/Users/ddfisher/test/test.py:7: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/ddfisher/src/mypy/mypy/__main__.py", line 5, in <module>
    main(None)
  File "/Users/ddfisher/src/mypy/mypy/main.py", line 41, in main
    res = type_check_only(sources, bin_dir, options)
  File "/Users/ddfisher/src/mypy/mypy/main.py", line 86, in type_check_only
    options=options)
  File "/Users/ddfisher/src/mypy/mypy/build.py", line 180, in build
    dispatch(sources, manager)
  File "/Users/ddfisher/src/mypy/mypy/build.py", line 1509, in dispatch
    process_graph(graph, manager)
  File "/Users/ddfisher/src/mypy/mypy/build.py", line 1689, in process_graph
    process_stale_scc(graph, scc)
  File "/Users/ddfisher/src/mypy/mypy/build.py", line 1773, in process_stale_scc
    if graph[id].type_check_second_pass():
  File "/Users/ddfisher/src/mypy/mypy/build.py", line 1443, in type_check_second_pass
    return self.type_checker.check_second_pass()
  File "/Users/ddfisher/src/mypy/mypy/checker.py", line 211, in check_second_pass
    self.accept(node)
  File "/Users/ddfisher/src/mypy/mypy/checker.py", line 237, in accept
    typ = node.accept(self)
  File "/Users/ddfisher/src/mypy/mypy/nodes.py", line 531, in accept
    return visitor.visit_func_def(self)
  File "/Users/ddfisher/src/mypy/mypy/checker.py", line 451, in visit_func_def
    self.check_method_override(defn)
  File "/Users/ddfisher/src/mypy/mypy/checker.py", line 852, in check_method_override
    self.check_method_or_accessor_override_for_base(defn, base)
  File "/Users/ddfisher/src/mypy/mypy/checker.py", line 861, in check_method_or_accessor_override_for_base
    self.check_method_override_for_base_with_name(defn, name, base)
  File "/Users/ddfisher/src/mypy/mypy/checker.py", line 879, in check_method_override_for_base_with_name
    typ = bind_self(self.function_type(defn), self.class_context[-1])
IndexError: list index out of range

@elazarg @JukkaL I think this is also related to #2193.

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

No branches or pull requests

1 participant