1
0
forked from VimPlug/jedi

Fix a very complicated issue with comprehensions.

This commit is contained in:
Dave Halter
2015-03-03 12:56:48 +01:00
parent 1520ebf557
commit 96add84459
2 changed files with 17 additions and 3 deletions

View File

@@ -41,7 +41,9 @@ def filter_after_position(names, position):
names_new = []
for n in names:
if n.start_pos[0] is not None and n.start_pos < position:
# Filter positions and also allow list comprehensions and lambdas.
if n.start_pos[0] is not None and n.start_pos < position \
or isinstance(n.get_definition(), (pr.CompFor, pr.Lambda)):
names_new.append(n)
return names_new
@@ -54,8 +56,6 @@ def filter_definition_names(names, origin, position=None):
# Just calculate the scope from the first
stmt = names[0].get_definition()
scope = stmt.get_parent_scope()
if isinstance(stmt, (pr.CompFor, pr.Lambda)):
return names
if not (isinstance(scope, er.FunctionExecution)
and isinstance(scope.base, er.LambdaWrapper)):

View File

@@ -135,6 +135,12 @@ a = [a for a in [1]]
#? int()
a[0]
y = 1.0
# Should not leak.
[y for y in [3]]
#? float()
y
a = [a for a in (1, 2)]
#? int()
a[0]
@@ -229,6 +235,14 @@ left, right = (i for i in
#? str()
left
# -----------------
# name resolution in comprehensions.
# -----------------
def x():
#? 22
[a for a in h if hio]
if hio: pass
# -----------------
# ternary operator