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

Unexpected comma in function arguments list #1112

Open
LeXofLeviafan opened this issue Sep 26, 2020 · 1 comment
Open

Unexpected comma in function arguments list #1112

LeXofLeviafan opened this issue Sep 26, 2020 · 1 comment

Comments

@LeXofLeviafan
Copy link

Suppose we have the following code:

foo = (bar, match, baz) ->

According to language docs, it doesn't include any reserved words, so it should compile… but instead it generates an outright confusing syntax error:
Parse error on line 1: Unexpected ','

After some fiddling, we narrow down the reason to the match word… But it wasn't used anywhere in the language, was it now?
We do a text search on the language webpage, just in case we forgot about it… And it does find a mention – but only in the changelog, as an experimental feature. So what, was it added but then removed later and they forgot to exclude it from the parser? Nope – after searching through the github issues we find out that the feature is present in the language, just never mentioned anywhere in the docs.

The problem here, of course, is that the match keyword is neither documented in the language docs – not even as a reserved word – nor does its usage produce a sensible error message (when used as an argument name).
Thus, I suggest doing one or more of the following:

  • Add the match feature to the language docs, possibly in a section named “Experimental features” (Missing documentation for match statement #936)
  • Add the full list of reserved words to the language docs, preferably somewhere in the beginning
  • Exclude the experimental/undocumented syntax from release builds of the parser
  • Detect when a reserved word is used as a function argument name and generate the error message accordingly (so that the programmer doesn't have trouble figuring out what went wrong when encountering it)
@rhendric
Copy link
Collaborator

The fourth option would be quite nice but I think we're limited by the parser generator we're using; Jison's error recovery facilities are... not great.

The third option is something I'm reluctant to do in a keep-the-lights-on context, so unless LiveScript starts gathering forward momentum again, I think experimental match is here to stay.

So that leaves the other two. I've suggested before that a glossary of keywords/symbols would be a good idea, and I still think so; maybe just a list of keywords is worth adding as an interim solution.

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

No branches or pull requests

2 participants