Skip to content

crash with generator in list comprehension #10189

@Akuli

Description

@Akuli

Crash Report

possibly related to #10188

Traceback

mypybug.py:7: 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.812
Traceback (most recent call last):
  File "mypy/semanal.py", line 4835, in accept
  File "mypy/nodes.py", line 1030, in accept
  File "mypy/semanal.py", line 3306, in visit_expression_stmt
  File "mypy/nodes.py", line 1956, in accept
  File "mypy/semanal.py", line 3883, in visit_list_comprehension
  File "mypy/nodes.py", line 1943, in accept
  File "mypy/semanal.py", line 3899, in visit_generator_expr
  File "mypy/nodes.py", line 1566, in accept
  File "mypy/semanal.py", line 3568, in visit_yield_from_expr
IndexError: list index out of range
mypybug.py:7: : note: use --pdb to drop into pdb

To Reproduce

from typing import Generator

def f() -> Generator[int, None, str]:
    yield 1
    return "lol"

[(yield from f()) for lel in range(5)]

Your Environment

  • Mypy version used: 0.812
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.7.3

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions