Skip to content

Unexpected comma in function arguments list #1112

@LeXofLeviafan

Description

@LeXofLeviafan

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)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions