forked from VimPlug/jedi
Avoid aborting search for yields when they are still reachable, see #683
This commit is contained in:
@@ -201,15 +201,15 @@ class BaseFunctionExecutionContext(ValueContext, TreeContextMixin):
|
|||||||
returns = funcdef.iter_return_stmts()
|
returns = funcdef.iter_return_stmts()
|
||||||
|
|
||||||
for r in returns:
|
for r in returns:
|
||||||
check = flow_analysis.reachability_check(self, funcdef, r)
|
if check_yields:
|
||||||
if check is flow_analysis.UNREACHABLE:
|
value_set |= ValueSet.from_sets(
|
||||||
debug.dbg('Return unreachable: %s', r)
|
lazy_value.infer()
|
||||||
|
for lazy_value in self._get_yield_lazy_value(r)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if check_yields:
|
check = flow_analysis.reachability_check(self, funcdef, r)
|
||||||
value_set |= ValueSet.from_sets(
|
if check is flow_analysis.UNREACHABLE:
|
||||||
lazy_value.infer()
|
debug.dbg('Return unreachable: %s', r)
|
||||||
for lazy_value in self._get_yield_lazy_value(r)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
children = r.children
|
children = r.children
|
||||||
@@ -218,9 +218,9 @@ class BaseFunctionExecutionContext(ValueContext, TreeContextMixin):
|
|||||||
value_set |= ValueSet([ctx])
|
value_set |= ValueSet([ctx])
|
||||||
else:
|
else:
|
||||||
value_set |= self.infer_node(children[1])
|
value_set |= self.infer_node(children[1])
|
||||||
if check is flow_analysis.REACHABLE:
|
if check is flow_analysis.REACHABLE:
|
||||||
debug.dbg('Return reachable: %s', r)
|
debug.dbg('Return reachable: %s', r)
|
||||||
break
|
break
|
||||||
return value_set
|
return value_set
|
||||||
|
|
||||||
def _get_yield_lazy_value(self, yield_expr):
|
def _get_yield_lazy_value(self, yield_expr):
|
||||||
|
|||||||
@@ -78,6 +78,28 @@ g = iter([1.0])
|
|||||||
#? float()
|
#? float()
|
||||||
next(g)
|
next(g)
|
||||||
|
|
||||||
|
x, y = Get()
|
||||||
|
#? int() str()
|
||||||
|
x
|
||||||
|
#? int() str()
|
||||||
|
x
|
||||||
|
|
||||||
|
class Iter:
|
||||||
|
def __iter__(self):
|
||||||
|
yield ""
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
v = 1
|
||||||
|
yield v
|
||||||
|
i += 1
|
||||||
|
a, b, c = Iter()
|
||||||
|
#? str() int()
|
||||||
|
a
|
||||||
|
#? str() int()
|
||||||
|
b
|
||||||
|
#? str() int()
|
||||||
|
c
|
||||||
|
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# __next__
|
# __next__
|
||||||
|
|||||||
Reference in New Issue
Block a user