diff --git a/jedi/parsing.py b/jedi/parsing.py index faf51729..3b157859 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -1693,6 +1693,18 @@ class PyFuzzyParser(object): s = [] if statement is None else [statement] f = ForFlow(s, first_pos, set_stmt) self.scope = self.scope.add_statement(f) + else: + debug.warning('syntax err, for flow started @%s', + self.start_pos[0]) + if statement is not None: + statement.parent = weakref.ref(self.scope) + if set_stmt is not None: + set_stmt.parent = weakref.ref(self.scope) + else: + debug.warning('syntax err, for flow incomplete @%s', + self.start_pos[0]) + if set_stmt is not None: + set_stmt.parent = weakref.ref(self.scope) elif tok in ['if', 'while', 'try', 'with'] + extended_flow: added_breaks = [] diff --git a/test/regression.py b/test/regression.py index 22c5f1b6..460ce1e1 100755 --- a/test/regression.py +++ b/test/regression.py @@ -158,6 +158,12 @@ class TestRegression(unittest.TestCase): s = "with open(" assert check(self.get_in_function_call(s), 'open', 0) + # jedi-vim #11 + s1 = "for sorted(" + assert check(self.get_in_function_call(s1), 'sorted', 0) + s2 = "for s in sorted(" + assert check(self.get_in_function_call(s2), 'sorted', 0) + def test_add_dynamic_mods(self): api.settings.additional_dynamic_modules = ['dynamic.py'] # Fictional module that defines a function.