Skip to content

Internal error with unresolved forward reference #4385

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
mitar opened this issue Dec 19, 2017 · 4 comments
Closed

Internal error with unresolved forward reference #4385

mitar opened this issue Dec 19, 2017 · 4 comments

Comments

@mitar
Copy link

mitar commented Dec 19, 2017

I am getting an internal error even with current master, version 0.570-dev-38337a8900052c40992d39bb09b1fcbb53a15d59.

RuntimeError: Internal error: unresolved forward reference
Traceback (most recent call last):
  File "/<redacted>/bin/mypy", line 11, in <module>
    load_entry_point('mypy===0.570-dev-38337a8900052c40992d39bb09b1fcbb53a15d59', 'console_scripts', 'mypy')()
  File "/<redacted>/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/<redacted>/lib/python3.6/site-packages/mypy/main.py", line 66, in main
    res = type_check_only(sources, bin_dir, options)
  File "/<redacted>/lib/python3.6/site-packages/mypy/main.py", line 119, in type_check_only
    options=options)
  File "/<redacted>/lib/python3.6/site-packages/mypy/build.py", line 218, in build
    graph = dispatch(sources, manager)
  File "/<redacted>/lib/python3.6/site-packages/mypy/build.py", line 2000, in dispatch
    process_graph(graph, manager)
  File "/<redacted>/lib/python3.6/site-packages/mypy/build.py", line 2304, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/<redacted>/lib/python3.6/site-packages/mypy/build.py", line 2474, in process_stale_scc
    graph[id].semantic_analysis_pass_three()
  File "/<redacted>/lib/python3.6/site-packages/mypy/build.py", line 1866, in semantic_analysis_pass_three
    self.options, patches)
  File "/<redacted>/lib/python3.6/site-packages/mypy/semanal_pass3.py", line 61, in visit_file
    self.accept(file_node)
  File "/<redacted>/lib/python3.6/site-packages/mypy/semanal_pass3.py", line 79, in accept
    node.accept(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/nodes.py", line 228, in accept
    return visitor.visit_mypy_file(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/traverser.py", line 30, in visit_mypy_file
    d.accept(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/nodes.py", line 699, in accept
    return visitor.visit_class_def(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/semanal_pass3.py", line 134, in visit_class_def
    super().visit_class_def(tdef)
  File "/<redacted>/lib/python3.6/site-packages/mypy/traverser.py", line 61, in visit_class_def
    o.defs.accept(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/nodes.py", line 759, in accept
    return visitor.visit_block(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/semanal_pass3.py", line 86, in visit_block
    super().visit_block(b)
  File "/<redacted>/lib/python3.6/site-packages/mypy/traverser.py", line 34, in visit_block
    s.accept(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/nodes.py", line 497, in accept
    return visitor.visit_func_def(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/semanal_pass3.py", line 92, in visit_func_def
    self.analyze(fdef.type, fdef)
  File "/<redacted>/lib/python3.6/site-packages/mypy/semanal_pass3.py", line 350, in analyze
    type.accept(analyzer)
  File "/<redacted>/lib/python3.6/site-packages/mypy/types.py", line 739, in accept
    return visitor.visit_callable_type(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/typeanal.py", line 771, in visit_callable_type
    arg_type.accept(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/types.py", line 475, in accept
    return visitor.visit_instance(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/typeanal.py", line 727, in visit_instance
    if not is_subtype(arg, bound):
  File "/<redacted>/lib/python3.6/site-packages/mypy/subtypes.py", line 83, in is_subtype
    ignore_declared_variance=ignore_declared_variance))
  File "/<redacted>/lib/python3.6/site-packages/mypy/types.py", line 543, in accept
    return visitor.visit_type_var(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/subtypes.py", line 204, in visit_type_var
    return is_subtype(left.upper_bound, self.right)
  File "/<redacted>/lib/python3.6/site-packages/mypy/subtypes.py", line 83, in is_subtype
    ignore_declared_variance=ignore_declared_variance))
  File "/<redacted>/lib/python3.6/site-packages/mypy/types.py", line 475, in accept
    return visitor.visit_instance(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/subtypes.py", line 169, in visit_instance
    zip(t.args, right.args, right.type.defn.type_vars))
  File "/<redacted>/lib/python3.6/site-packages/mypy/subtypes.py", line 168, in <genexpr>
    for lefta, righta, tvar in
  File "/<redacted>/lib/python3.6/site-packages/mypy/subtypes.py", line 38, in check_type_parameter
    return is_subtype(lefta, righta, check_type_parameter)
  File "/<redacted>/lib/python3.6/site-packages/mypy/subtypes.py", line 83, in is_subtype
    ignore_declared_variance=ignore_declared_variance))
  File "/<redacted>/lib/python3.6/site-packages/mypy/types.py", line 1415, in accept
    return visitor.visit_forwardref_type(self)
  File "/<redacted>/lib/python3.6/site-packages/mypy/types.py", line 1500, in visit_forwardref_type
    raise RuntimeError('Internal error: unresolved forward reference')
RuntimeError: Internal error: unresolved forward reference

I made a reproduction here: https://github.com/mitar/forward-reference-test

Run mypy bar.

@ilevkivskyi
Copy link
Member

This is a duplicate of #4200

@mitar
Copy link
Author

mitar commented Dec 19, 2017

I am not sure. For me things work until I define the compute method:

class Bary(typing.Generic[Container]):
    def compute(self) -> Container:
        pass

@ilevkivskyi
Copy link
Member

You can check that #4384 will fix your repro as well.

@mitar
Copy link
Author

mitar commented Dec 19, 2017

It does. Perfect!

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

2 participants