Visitar URL original
def a(x=3, b, c) should not be accepted · Issue #89 · go-python/gpython · GitHub
The Wayback Machine - https://web.archive.org/web/20200910210633/https://github.com/go-python/gpython/issues/89
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

def a(x=3, b, c) should not be accepted #89

Open
corona10 opened this issue Sep 23, 2019 · 4 comments
Open

def a(x=3, b, c) should not be accepted #89

corona10 opened this issue Sep 23, 2019 · 4 comments
Assignees

Comments

@corona10
Copy link
Member

@corona10 corona10 commented Sep 23, 2019 •

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'"
@corona10 corona10 self-assigned this Sep 23, 2019
@tim-st
Copy link
Contributor

@tim-st tim-st commented Sep 23, 2019 •

Or more general: all kwargs must be declared last. The following currently also works in gpython:

def a(b, x=3, c):
  pass
@ncw ncw added the bug label Sep 28, 2019
@ncw
Copy link
Collaborator

@ncw ncw commented Sep 28, 2019 •

I think this is probably a bug in parser/grammar.y. This FIXME looks relevant ;-)

// FIXME this isn't checking all the python rules for args before kwargs etc

@HyeockJinKim
Copy link
Contributor

@HyeockJinKim HyeockJinKim commented Oct 11, 2019

If no one tried this issue, can I try it?

@corona10
Copy link
Member Author

@corona10 corona10 commented Oct 11, 2019

@HyeockJinKim Yes please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.