gpython
gpython copied to clipboard
def a(x=3, b, c) should not be accepted
But accepted in gpython it should be raised Syntax error.
cpython
>>> def a(x=3, b, c):
... pass
...
File "<stdin>", line 1
SyntaxError: non-default argument follows default argument
gpython
>>> def a(x=3, b, c):
... pass
...
>>> a()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FIXME line of source goes here
TypeError: "a() missing 2 required positional arguments: 'x' and 'b'"
Or more general: all kwargs must be declared last. The following currently also works in gpython:
def a(b, x=3, c):
pass
I think this is probably a bug in parser/grammar.y. This FIXME looks relevant ;-)
https://github.com/go-python/gpython/blob/4b347aa2bb5acd7fdd2fcb9a52b463f6c5535740/parser/grammar.y#L464
If no one tried this issue, can I try it?
@HyeockJinKim Yes please