mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
for flows triggered an exception if goto_assignments was used on the keyword. found with the help of sith.py
This commit is contained in:
@@ -266,6 +266,9 @@ class Script(object):
|
||||
stmt = r.module.statements[-1]
|
||||
except IndexError:
|
||||
raise NotFoundError()
|
||||
if isinstance(stmt, pr.Flow):
|
||||
raise NotFoundError()
|
||||
|
||||
user_stmt = self._parser.user_stmt()
|
||||
if user_stmt is None:
|
||||
# Set the start_pos to a pseudo position, that doesn't exist but works
|
||||
|
||||
@@ -679,10 +679,12 @@ class ForFlow(Flow):
|
||||
super(ForFlow, self).__init__(module, 'for', inputs, start_pos)
|
||||
|
||||
self.set_stmt = set_stmt
|
||||
set_stmt.parent = self.use_as_parent
|
||||
self.is_list_comp = is_list_comp
|
||||
|
||||
if set_stmt is not None:
|
||||
set_stmt.parent = self.use_as_parent
|
||||
self.set_vars = set_stmt.get_defined_names()
|
||||
|
||||
for s in self.set_vars:
|
||||
s.parent.parent = self.use_as_parent
|
||||
s.parent = self.use_as_parent
|
||||
|
||||
@@ -94,3 +94,8 @@ def test_completion_on_complex_literals():
|
||||
_check_number('4.0j.', 'complex')
|
||||
# No dot no completion
|
||||
assert api.Script('4j').completions() == []
|
||||
|
||||
|
||||
def test_goto_assignments_on_for():
|
||||
with raises(api.NotFoundError):
|
||||
api.Script('for').goto_assignments()
|
||||
|
||||
Reference in New Issue
Block a user