from typing import List
def list_comp(self) -> List[int]:
if True:
return [i for i in [5]]
return [i for i in [5]]
Traceback (most recent call last):
File "/Users/shantanu/dev/mypy/build/setup.py", line 5, in <module>
ext_modules=mypycify(['rep.py'], opt_level="3", debug_level="1"),
File "/Users/shantanu/dev/mypy/mypyc/build.py", line 494, in mypycify
groups, group_cfilenames = mypyc_build(
File "/Users/shantanu/dev/mypy/mypyc/build.py", line 405, in mypyc_build
group_cfiles, ops_text = generate_c(all_sources, options, groups, fscache,
File "/Users/shantanu/dev/mypy/mypyc/build.py", line 207, in generate_c
modules, ctext = emitmodule.compile_modules_to_c(
File "/Users/shantanu/dev/mypy/mypyc/codegen/emitmodule.py", line 414, in compile_modules_to_c
modules = compile_modules_to_ir(result, mapper, compiler_options, errors)
File "/Users/shantanu/dev/mypy/mypyc/codegen/emitmodule.py", line 258, in compile_modules_to_ir
scc_ir = compile_scc_to_ir(trees, result, mapper, compiler_options, errors)
File "/Users/shantanu/dev/mypy/mypyc/codegen/emitmodule.py", line 209, in compile_scc_to_ir
modules = build_ir(
File "/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/main.py", line 83, in build_ir
transform_mypy_file(builder, module)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/main.py", line 128, in transform_mypy_file
builder.accept(node)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/builder.py", line 194, in accept
node.accept(self.visitor)
File "/Users/shantanu/dev/mypy/mypy/nodes.py", line 758, in accept
return visitor.visit_func_def(self)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/visitor.py", line 117, in visit_func_def
transform_func_def(self.builder, fdef)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/function.py", line 69, in transform_func_def
func_ir, func_reg = gen_func_item(builder, fdef, fdef.name, builder.mapper.fdef_to_sig(fdef))
File "/Users/shantanu/dev/mypy/mypyc/irbuild/function.py", line 296, in gen_func_item
builder.accept(fitem.body)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/builder.py", line 194, in accept
node.accept(self.visitor)
File "/Users/shantanu/dev/mypy/mypy/nodes.py", line 1110, in accept
return visitor.visit_block(self)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/visitor.py", line 126, in visit_block
transform_block(self.builder, block)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/statement.py", line 47, in transform_block
builder.accept(stmt)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/builder.py", line 194, in accept
node.accept(self.visitor)
File "/Users/shantanu/dev/mypy/mypy/nodes.py", line 1267, in accept
return visitor.visit_return_stmt(self)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/visitor.py", line 134, in visit_return_stmt
transform_return_stmt(self.builder, stmt)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/statement.py", line 70, in transform_return_stmt
retval = builder.accept(stmt.expr)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/builder.py", line 180, in accept
res = node.accept(self.visitor)
File "/Users/shantanu/dev/mypy/mypy/nodes.py", line 2136, in accept
return visitor.visit_list_comprehension(self)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/visitor.py", line 246, in visit_list_comprehension
return transform_list_comprehension(self.builder, expr)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/expression.py", line 810, in transform_list_comprehension
return translate_list_comprehension(builder, o.generator)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/for_helpers.py", line 200, in translate_list_comprehension
comprehension_helper(builder, loop_params, gen_inner_stmts, gen.line)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/for_helpers.py", line 271, in comprehension_helper
handle_loop(loop_params)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/for_helpers.py", line 237, in handle_loop
for_loop_helper(builder, index, expr,
File "/Users/shantanu/dev/mypy/mypyc/irbuild/for_helpers.py", line 60, in for_loop_helper
for_gen = make_for_loop_generator(builder, index, expr, body_block, normal_loop_exit, line)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/for_helpers.py", line 398, in make_for_loop_generator
item_type = builder._analyze_iterable_item_type(expr)
File "/Users/shantanu/dev/mypy/mypyc/irbuild/builder.py", line 795, in _analyze_iterable_item_type
iterable = get_proper_type(self.types[expr])
rep.py:6: KeyError: <mypy.nodes.ListExpr object at 0x1045257c0>