mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 21:54:54 +08:00
Fixed all cases that are called "can't assign/delete %s".
This commit is contained in:
@@ -473,9 +473,17 @@ class ErrorFinder(Normalizer):
|
|||||||
self._add_syntax_error(message, node)
|
self._add_syntax_error(message, node)
|
||||||
elif type_ == 'test':
|
elif type_ == 'test':
|
||||||
error = 'conditional expression'
|
error = 'conditional expression'
|
||||||
elif type_ == 'atom_expr':
|
elif type_ in ('atom_expr', 'power'):
|
||||||
if node.children[0] == 'await':
|
if node.children[0] == 'await':
|
||||||
error = 'await expression'
|
error = 'await expression'
|
||||||
|
elif node.children[-2] == '**':
|
||||||
|
error = 'operator'
|
||||||
|
else:
|
||||||
|
# Has a trailer
|
||||||
|
trailer = node.children[-1]
|
||||||
|
assert trailer.type == 'trailer'
|
||||||
|
if trailer.children[0] == '(':
|
||||||
|
error = 'function call'
|
||||||
elif type_ in ('testlist_star_expr', 'exprlist'):
|
elif type_ in ('testlist_star_expr', 'exprlist'):
|
||||||
for child in node.children[::2]:
|
for child in node.children[::2]:
|
||||||
self._check_assignment(child, is_deletion)
|
self._check_assignment(child, is_deletion)
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ def test_indentation_errors(code, positions):
|
|||||||
'f(x=2, y)',
|
'f(x=2, y)',
|
||||||
'f(**x, *y)',
|
'f(**x, *y)',
|
||||||
'f(**x, y=3, z)',
|
'f(**x, y=3, z)',
|
||||||
|
# All assignment tests
|
||||||
'lambda a: 1 = 1',
|
'lambda a: 1 = 1',
|
||||||
'[x for x in y] = 1',
|
'[x for x in y] = 1',
|
||||||
'{x for x in y} = 1',
|
'{x for x in y} = 1',
|
||||||
@@ -116,6 +117,7 @@ def test_indentation_errors(code, positions):
|
|||||||
'b"" = 1',
|
'b"" = 1',
|
||||||
'"" "" = 1',
|
'"" "" = 1',
|
||||||
'1 | 1 = 3',
|
'1 | 1 = 3',
|
||||||
|
'1**1 = 3',
|
||||||
'~ 1 = 3',
|
'~ 1 = 3',
|
||||||
'not 1 = 3',
|
'not 1 = 3',
|
||||||
'1 and 1 = 3',
|
'1 and 1 = 3',
|
||||||
@@ -126,6 +128,7 @@ def test_indentation_errors(code, positions):
|
|||||||
'(True,) = x',
|
'(True,) = x',
|
||||||
'([False], a) = x',
|
'([False], a) = x',
|
||||||
'a, 1 = x',
|
'a, 1 = x',
|
||||||
|
'foo() = 1',
|
||||||
|
|
||||||
# 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