Skip to content

Fix hang reporting more (follow-up to #6872) #6875

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

Merged
merged 1 commit into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mypy/newsemanal/semanal_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ def process_top_level_function(analyzer: 'NewSemanticAnalyzer',
while deferred:
iteration += 1
if iteration == MAX_ITERATIONS:
analyzer.report_hang()
# Just pick some module inside the current SCC for error context.
assert state.tree is not None
with analyzer.file_context(state.tree, state.tree.path, state.options):
analyzer.report_hang()
break
if not (deferred or incomplete) or final_iteration:
# OK, this is one last pass, now missing names will be reported.
Expand Down
6 changes: 6 additions & 0 deletions test-data/unit/check-newsemanal.test
Original file line number Diff line number Diff line change
Expand Up @@ -2243,3 +2243,9 @@ force1(reveal_type(var1)) # E: Revealed type is 'Literal[1]'
class A(A): ...
[out]
main: error: Internal error: maximum semantic analysis iteration count reached

[case testNewAnalyzerReportLoopInMRO2]
def f() -> None:
class A(A): ...
[out]
main: error: Internal error: maximum semantic analysis iteration count reached