You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generator expression without parenthesis does not raise SyntaxError #84
changed the title [-]Generator expression without parenthesis[/-][+]Generator expression without parenthesis does not raise SyntaxError[/+]on Jul 20, 2022
>>> class A(x for x in range(10)): pass
File "<stdin>", line 1
class A(x for x in range(10)): pass
^
SyntaxError: expected ':'
RustPython:
>>>>> class A(x for x in range(10)): pass
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
This is SyntaxError but RustPython is not catching it.
Activity
[-]Generator expression without parenthesis[/-][+]Generator expression without parenthesis does not raise SyntaxError[/+]youknowone commentedon Jul 20, 2022
This is allowed only for single-argument function call.
In
python.lalrpopI seeFunctionArgumentis including Generator stuff. I guess that part is expected to be moved toArgumentListpart.key262yek commentedon Jul 21, 2022
I try to change
parse_argsfunction inArgumentListFirst, I checked whether the generator expression is single-argument or not.
But, in this way, we cannot figure out that the generator at the first time were parenthesized or not.
Following statements all raise errors.
It's because, as we can see in the parsing algorithm of function argument, NamedExpressionTest can be a generator expression itself.
Hence, I add boolean attribute to result of FunctionArgument parsing, which contains whether the generator expression were parenthesized or not.
and change the parse_args function as follows.
Question
Question is that, does it seem okay to add new attribute in lalrpop?
Is there any other way to resolve it without adding new structure?
any idea?
youknowone commentedon Jul 23, 2022
More above than ArgumentList.
cpython:
RustPython:
This is
SyntaxErrorbut RustPython is not catching it.In CPython, this is handled by
t_primary:https://github.com/python/cpython/blob/3.10/Grammar/python.gram#L823-L824
which not used for class definition. (
class_defis usingargumentshttps://github.com/python/cpython/blob/3.10/Grammar/python.gram#L489-L495)My suggestion is creating one more layer like cpython.