diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index bf81da6..523252a 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -141,6 +141,14 @@ class ErrorFinder(Normalizer): and not self._context.is_async_funcdef(): message = "asynchronous comprehension outside of an asynchronous function" self._add_syntax_error(message, node) + elif node.type == 'arglist': + first_arg = node.children[0] + if first_arg.type == 'argument' \ + and first_arg.children[1].type == 'comp_for' \ + and len(node.children) >= 2: + # foo(x for x in [], b) + message = "Generator expression must be parenthesized if not sole argument" + self._add_syntax_error(message, node) yield diff --git a/test/test_python_errors.py b/test/test_python_errors.py index fd564a0..3b60070 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -71,6 +71,7 @@ def test_indentation_errors(code, positions): 'return', 'yield', 'try: pass\nexcept: pass\nexcept X: pass', + 'f(x for x in bar, 1)', # IndentationError ' foo',