mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-15 08:57:11 +08:00
Add issues if users want to assign to operators.
This commit is contained in:
@@ -473,6 +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':
|
||||||
|
if node.children[0] == 'await':
|
||||||
|
error = 'await expression'
|
||||||
|
elif type_ in ('testlist_star_expr', 'exprlist'):
|
||||||
|
for child in node.children[::2]:
|
||||||
|
self._check_assignment(child, is_deletion)
|
||||||
|
elif ('expr' in type_ and type_ != 'star_expr' # is a substring
|
||||||
|
or '_test' in type_
|
||||||
|
or type_ in ('term', 'factor')):
|
||||||
|
error = 'operator'
|
||||||
|
|
||||||
print(node)
|
print(node)
|
||||||
|
|
||||||
if error is not None:
|
if error is not None:
|
||||||
|
|||||||
@@ -115,11 +115,17 @@ def test_indentation_errors(code, positions):
|
|||||||
'b"" = 1',
|
'b"" = 1',
|
||||||
'b"" = 1',
|
'b"" = 1',
|
||||||
'"" "" = 1',
|
'"" "" = 1',
|
||||||
|
'1 | 1 = 3',
|
||||||
|
'~ 1 = 3',
|
||||||
|
'not 1 = 3',
|
||||||
|
'1 and 1 = 3',
|
||||||
'def foo(): (yield 1) = 3',
|
'def foo(): (yield 1) = 3',
|
||||||
'def foo(): x = yield 1 = 3',
|
'def foo(): x = yield 1 = 3',
|
||||||
|
'async def foo(): await x = 3',
|
||||||
'(a if a else a) = a',
|
'(a if a else a) = a',
|
||||||
'(True,) = x',
|
'(True,) = x',
|
||||||
'([False], a) = x',
|
'([False], a) = x',
|
||||||
|
'a, 1 = x',
|
||||||
|
|
||||||
# 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