Closed
Description
Type checking the following program causes a crash (simplified from a real-world example):
from typing import List, NewType, Union
N = NewType('N', XXX)
x: List[Union[N, int]]
Here's the traceback:
$ mypy --show-traceback t/rt.py
t/rt.py:3: error: Argument 2 to NewType(...) must be subclassable (got "Any")
t/rt.py:3: error: Name 'XXX' is not defined
t/rt.py:1: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.560-dev-fcd91d00253449ea2571f1ffdcb5bb587ab7d8a5
Traceback (most recent call last):
File "/Users/jukka/src/mypy/scripts/mypy", line 6, in <module>
main(__file__)
File "/Users/jukka/src/mypy/mypy/main.py", line 66, in main
res = type_check_only(sources, bin_dir, options)
File "/Users/jukka/src/mypy/mypy/main.py", line 119, in type_check_only
options=options)
File "/Users/jukka/src/mypy/mypy/build.py", line 218, in build
graph = dispatch(sources, manager)
File "/Users/jukka/src/mypy/mypy/build.py", line 2000, in dispatch
process_graph(graph, manager)
File "/Users/jukka/src/mypy/mypy/build.py", line 2304, in process_graph
process_stale_scc(graph, scc, manager)
File "/Users/jukka/src/mypy/mypy/build.py", line 2474, in process_stale_scc
graph[id].semantic_analysis_pass_three()
File "/Users/jukka/src/mypy/mypy/build.py", line 1866, in semantic_analysis_pass_three
self.options, patches)
File "/Users/jukka/src/mypy/mypy/semanal_pass3.py", line 61, in visit_file
self.accept(file_node)
File "/Users/jukka/src/mypy/mypy/semanal_pass3.py", line 79, in accept
node.accept(self)
File "/Users/jukka/src/mypy/mypy/nodes.py", line 228, in accept
return visitor.visit_mypy_file(self)
File "/Users/jukka/src/mypy/mypy/traverser.py", line 30, in visit_mypy_file
d.accept(self)
File "/Users/jukka/src/mypy/mypy/nodes.py", line 805, in accept
return visitor.visit_assignment_stmt(self)
File "/Users/jukka/src/mypy/mypy/semanal_pass3.py", line 200, in visit_assignment_stmt
self.analyze(s.type, s)
File "/Users/jukka/src/mypy/mypy/semanal_pass3.py", line 348, in analyze
type.accept(analyzer)
File "/Users/jukka/src/mypy/mypy/types.py", line 475, in accept
return visitor.visit_instance(self)
File "/Users/jukka/src/mypy/mypy/typeanal.py", line 727, in visit_instance
if not is_subtype(arg, bound):
File "/Users/jukka/src/mypy/mypy/subtypes.py", line 83, in is_subtype
ignore_declared_variance=ignore_declared_variance))
File "/Users/jukka/src/mypy/mypy/types.py", line 1230, in accept
return visitor.visit_union_type(self)
File "/Users/jukka/src/mypy/mypy/subtypes.py", line 312, in visit_union_type
for item in left.items)
File "/Users/jukka/src/mypy/mypy/subtypes.py", line 312, in <genexpr>
for item in left.items)
File "/Users/jukka/src/mypy/mypy/subtypes.py", line 83, in is_subtype
ignore_declared_variance=ignore_declared_variance))
File "/Users/jukka/src/mypy/mypy/types.py", line 1415, in accept
return visitor.visit_forwardref_type(self)
File "/Users/jukka/src/mypy/mypy/types.py", line 1500, in visit_forwardref_type
raise RuntimeError('Internal error: unresolved forward reference')
RuntimeError: Internal error: unresolved forward reference
t/rt.py:1: : note: use --pdb to drop into pdb
Metadata
Metadata
Assignees
Labels
No labels