mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-15 18:17:07 +08:00
Fix an issue with Function/Flow combination in the fast parser.
This commit is contained in:
@@ -542,6 +542,7 @@ class FastTokenizer(object):
|
||||
self._indent_counter += 1
|
||||
elif typ == DEDENT:
|
||||
self._indent_counter -= 1
|
||||
print('DEDENT', self._flow_indent_counter, start_pos, self._indent_counter)
|
||||
if self._in_flow and self._indent_counter == self._flow_indent_counter:
|
||||
self._in_flow = False
|
||||
self._next_dedent_noclose = True
|
||||
@@ -549,10 +550,11 @@ class FastTokenizer(object):
|
||||
|
||||
if self.previous[0] in (NEWLINE, INDENT, DEDENT):
|
||||
if self.previous[0] == DEDENT:
|
||||
if not self._next_dedent_noclose:
|
||||
self._first_stmt = False
|
||||
return self._close()
|
||||
if not self._in_flow:
|
||||
if not self._next_dedent_noclose:
|
||||
self._first_stmt = False
|
||||
return self._close()
|
||||
|
||||
self._next_dedent_noclose = False
|
||||
# Check for NEWLINE, which symbolizes the indent.
|
||||
#print('X', repr(value), tokenize.tok_name[typ])
|
||||
|
||||
@@ -142,6 +142,20 @@ def test_for():
|
||||
check_fp(src, 1)
|
||||
|
||||
|
||||
def test_func_with_if():
|
||||
src = dedent("""\
|
||||
def recursion(a):
|
||||
if foo:
|
||||
return recursion(a)
|
||||
else:
|
||||
if bar:
|
||||
return inexistent
|
||||
else:
|
||||
return a
|
||||
""")
|
||||
check_fp(src, 1)
|
||||
|
||||
|
||||
def test_incomplete_function():
|
||||
source = '''return ImportErr'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user