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

Parser: allow trailing comma after named arguments in index notation #4784

Conversation

makenowjust
Copy link
Contributor

@makenowjust makenowjust commented Aug 3, 2017

Fix #4782

For example, current compiler cannot compile this:

a = [1, 2, 3]
a[
  index: 1,
]
# Syntax error in foo.cr:4: expected named argument, not ]

Because the compiler does not allow trailing comma after named arguments in index notation. This fixes it so above is now working.


Crystal::Parser#parse_named_args misses checking :"]" token following :"," token (this means the case of trailing comma in index notation.). I fixed this correctly.

…tation

Fix crystal-lang#4782

For example, current compiler cannot compile this:

    a = [1, 2, 3]
    a[
      index: 1,
    ]
    # Syntax error in foo.cr:4: expected named argument, not ]

Because the compiler does not allow comma after named arguments in index
notation. This fixes it so above is now working.
@makenowjust makenowjust mentioned this pull request Aug 3, 2017
@makenowjust makenowjust changed the title Parser: allow to use trailing comma after named arguments in index notation Parser: allow trailing comma after named arguments in index notation Aug 3, 2017
@makenowjust
Copy link
Contributor Author

🏓

@mverzilli
Copy link

Using that emoji made it really difficult for me not to approve this PR :D

@makenowjust
Copy link
Contributor Author

Sorry. 🏓 means ping pong (table tennis), so I intended just "ping".

@RX14 RX14 merged commit 53c4431 into crystal-lang:master Aug 16, 2017
@RX14 RX14 added this to the Next milestone Aug 16, 2017
@makenowjust makenowjust deleted the fix/crystal-parser/allow-trailing-comma-in-index branch August 16, 2017 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatter bug
3 participants