forked from VimPlug/jedi
incomplete functions shouldn't cause any trouble. fixes #429.
This commit is contained in:
@@ -555,8 +555,9 @@ class Parser(object):
|
|||||||
elif tok_str in ('return', 'yield'):
|
elif tok_str in ('return', 'yield'):
|
||||||
s = tok.start_pos
|
s = tok.start_pos
|
||||||
self.freshscope = False
|
self.freshscope = False
|
||||||
# add returns to the scope
|
# Add returns to the scope
|
||||||
func = self._scope.get_parent_until(pr.Function)
|
# Should be a function, otherwise just add it to a module!
|
||||||
|
func = self._scope.get_parent_until((pr.Function, pr.Module))
|
||||||
if tok_str == 'yield':
|
if tok_str == 'yield':
|
||||||
func.is_generator = True
|
func.is_generator = True
|
||||||
|
|
||||||
|
|||||||
@@ -78,3 +78,10 @@ def test_change_and_undo():
|
|||||||
fp('a')
|
fp('a')
|
||||||
fp('b')
|
fp('b')
|
||||||
fp('a')
|
fp('a')
|
||||||
|
|
||||||
|
|
||||||
|
def test_incomplete_function():
|
||||||
|
source = '''return ImportErr'''
|
||||||
|
|
||||||
|
script = jedi.Script(dedent(source), 1, 3)
|
||||||
|
assert script.completions()
|
||||||
|
|||||||
Reference in New Issue
Block a user