Skip to content

crash when type checking a break outside loop #1571

@rwbarton

Description

@rwbarton

On the program

break

mypy crashes with the error

Traceback (most recent call last):
  File "/Users/rbarton/mypy/scripts/mypy", line 6, in <module>
    main(__file__)
[...]
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 2028, in visit_break_stmt
    self.binder.allow_jump(self.binder.loop_frames[-1] - 1)
IndexError: list index out of range

*** INTERNAL ERROR ***

break.py:1: error: Internal error -- please report a bug at https://github.com/python/mypy/issues

NOTE: you can use "mypy --pdb ..." to drop into the debugger when this happens.

Semantic analysis actually identifies that there is a break outside a loop and "fails", but this failure isn't fatal and mypy goes on to type check the module and crashes before printing the error. Not sure what the cleanest fix is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions