Skip to content

Commit

Permalink
Fix spurious "cycle in function expansion" errors. (#3504)
Browse files Browse the repository at this point in the history
Most of these (at least) seem to be due to a function being analyzed
multiple times, and the 'expanded' list filling up with 2 or more
references to the same FuncDef.

If there are other reasons they will still trigger the same error, but
at least for mypy itself, the error no longer appears with this simple
fix.

Fixes #3503.
  • Loading branch information
gvanrossum committed Jun 6, 2017
1 parent 7b7c7ad commit cbb4ba8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/stats.py
Expand Up @@ -57,7 +57,7 @@ def __init__(self, inferred: bool, typemap: Dict[Expression, Type] = None,

def visit_func_def(self, o: FuncDef) -> None:
self.line = o.line
if len(o.expanded) > 1:
if len(o.expanded) > 1 and o.expanded != [o] * len(o.expanded):
if o in o.expanded:
print('ERROR: cycle in function expansion; skipping')
return
Expand Down

0 comments on commit cbb4ba8

Please sign in to comment.