mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-20 19:31:18 +08:00
Handle nested statements.
This commit is contained in:
@@ -448,9 +448,16 @@ class ErrorFinder(Normalizer):
|
||||
if error is None:
|
||||
if second.type in ('dictorsetmaker', 'string'):
|
||||
error = 'literal'
|
||||
elif first == '(':
|
||||
elif first in ('(', '['):
|
||||
if second.type == 'yield_expr':
|
||||
error = 'yield expression'
|
||||
elif second.type == 'testlist_comp':
|
||||
# This is not a comprehension, they were handled
|
||||
# further above.
|
||||
for child in second.children[::2]:
|
||||
self._check_assignment(child, is_deletion)
|
||||
else: # Everything handled, must be useless brackets.
|
||||
self._check_assignment(second, is_deletion)
|
||||
elif type_ == 'keyword':
|
||||
error = 'keyword'
|
||||
elif type_ == 'operator':
|
||||
@@ -464,6 +471,9 @@ class ErrorFinder(Normalizer):
|
||||
# This one seems to be a slightly different warning in Python.
|
||||
message = 'assignment to yield expression not possible'
|
||||
self._add_syntax_error(message, node)
|
||||
elif type_ == 'test':
|
||||
error = 'conditional expression'
|
||||
print(node)
|
||||
|
||||
if error is not None:
|
||||
message = "can't %s %s" % ("delete" if is_deletion else "assign to", error)
|
||||
|
||||
@@ -116,10 +116,10 @@ def test_indentation_errors(code, positions):
|
||||
'b"" = 1',
|
||||
'"" "" = 1',
|
||||
'def foo(): (yield 1) = 3',
|
||||
'def foo(): x = yield 1 = 3'
|
||||
'',
|
||||
#'(True,) = x',
|
||||
#'([False], a) = x',
|
||||
'def foo(): x = yield 1 = 3',
|
||||
'(a if a else a) = a',
|
||||
'(True,) = x',
|
||||
'([False], a) = x',
|
||||
|
||||
# SyntaxErrors from Python/symtable.c
|
||||
'def f(x, x): pass',
|
||||
|
||||
Reference in New Issue
Block a user