mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-09 06:04:54 +08:00
Fix the final issue with expr_list.
This commit is contained in:
@@ -157,6 +157,12 @@ class ErrorFinder(Normalizer):
|
|||||||
elif default_except is not None:
|
elif default_except is not None:
|
||||||
self._add_syntax_error("default 'except:' must be last", default_except)
|
self._add_syntax_error("default 'except:' must be last", default_except)
|
||||||
|
|
||||||
|
if node.type == 'for_stmt':
|
||||||
|
# Some of the nodes here are already used, so no else if
|
||||||
|
expr_list = node.children[1]
|
||||||
|
if expr_list.type != 'expr_list': # Already handled.
|
||||||
|
self._check_assignment(expr_list)
|
||||||
|
|
||||||
with self._context.add_block(node):
|
with self._context.add_block(node):
|
||||||
if len(self._context.blocks) == _MAX_BLOCK_SIZE:
|
if len(self._context.blocks) == _MAX_BLOCK_SIZE:
|
||||||
self._add_syntax_error("too many statically nested blocks", node)
|
self._add_syntax_error("too many statically nested blocks", node)
|
||||||
@@ -212,6 +218,11 @@ class ErrorFinder(Normalizer):
|
|||||||
message = "iterable unpacking cannot be used in comprehension"
|
message = "iterable unpacking cannot be used in comprehension"
|
||||||
self._add_syntax_error(message, node)
|
self._add_syntax_error(message, node)
|
||||||
elif node.type == 'comp_for':
|
elif node.type == 'comp_for':
|
||||||
|
# Some of the nodes here are already used, so no else if
|
||||||
|
expr_list = node.children[1 + int(node.children[0] == 'async')]
|
||||||
|
if expr_list.type != 'expr_list': # Already handled.
|
||||||
|
self._check_assignment(expr_list)
|
||||||
|
|
||||||
if node.children[0] == 'async' \
|
if node.children[0] == 'async' \
|
||||||
and not self._context.is_async_funcdef():
|
and not self._context.is_async_funcdef():
|
||||||
message = "asynchronous comprehension outside of an asynchronous function"
|
message = "asynchronous comprehension outside of an asynchronous function"
|
||||||
@@ -354,12 +365,6 @@ class ErrorFinder(Normalizer):
|
|||||||
for expr in node.children[::2]:
|
for expr in node.children[::2]:
|
||||||
self._check_assignment(expr)
|
self._check_assignment(expr)
|
||||||
|
|
||||||
# Some of the nodes here are already used, so no else if
|
|
||||||
if node.type in ('for_stmt', 'comp_for', 'list_for'):
|
|
||||||
child = node.children[1]
|
|
||||||
if child.type != 'expr_list': # Already handled.
|
|
||||||
self._check_assignment(child)
|
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
def visit_leaf(self, leaf):
|
def visit_leaf(self, leaf):
|
||||||
|
|||||||
@@ -129,6 +129,13 @@ def test_indentation_errors(code, positions):
|
|||||||
'([False], a) = x',
|
'([False], a) = x',
|
||||||
'a, 1 = x',
|
'a, 1 = x',
|
||||||
'foo() = 1',
|
'foo() = 1',
|
||||||
|
# Cases without the equals but other assignments.
|
||||||
|
'with x as foo(): pass',
|
||||||
|
'del None',
|
||||||
|
'del bar, 1',
|
||||||
|
'for x, 1 in []: pass',
|
||||||
|
'for (not 1) in []: pass',
|
||||||
|
'[x for 1 in y]',
|
||||||
|
|
||||||
# SyntaxErrors from Python/symtable.c
|
# SyntaxErrors from Python/symtable.c
|
||||||
'def f(x, x): pass',
|
'def f(x, x): pass',
|
||||||
|
|||||||
Reference in New Issue
Block a user