From 2b912cb75ad2d196aae87da62b51767f1f305aa9 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 29 Nov 2014 01:29:21 +0100 Subject: [PATCH] The func/class dictionaries must be changed if some scopes are removed by the parser's error recovery. --- jedi/parser/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jedi/parser/__init__.py b/jedi/parser/__init__.py index ddff9dcb..5c3f828a 100644 --- a/jedi/parser/__init__.py +++ b/jedi/parser/__init__.py @@ -243,6 +243,9 @@ class Parser(object): except ValueError: pass # This may happen with CompFor. + for dfa, state, node in stack[start_index:]: + clear_names(children=node[1]) + failed_stack = [] found = False for dfa, state, (typ, nodes) in stack[start_index:]: @@ -251,13 +254,12 @@ class Parser(object): if found: symbol = grammar.number2symbol[typ] failed_stack.append((symbol, nodes)) + if nodes and nodes[0] in ('def', 'class'): + self.scope_names_stack.pop() if failed_stack: err = ErrorStatement(failed_stack, value, start_pos) self.error_statement_stacks.append(err) - for dfa, state, node in stack[start_index:]: - clear_names(children=node[1]) - stack[start_index:] = [] def _tokenize(self, tokenizer):