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

Table's element identifier must be followed (glued) by colon. Parse error if do not #376

Closed
ghost opened this issue Nov 19, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 19, 2018

When writing table literals, the colon ':' must be just next (glued) to the identifier.

The following will generate a parse error

table = {
  id     : @id,
  handler: @handler
}

But the following will works just fine

-- Not aligned
table = {
  id: @id,
  handler: @handler
}

-- Aligned
table = {
  id:      @id,
  handler: @handler
}

P.S. The error happens with any type of table literals' syntaxes

-- Fails
table = id : @id, handler: @handler

-- Pass
table = id: @id, handler: @handler

---

-- Fails
table =
  id     : @id,
  handler: @handler

-- Pass
table =
  id:      @id,
  handler: @handler

---

-- Fails
values = {
  1,2,3,4
  5,6,7,8
  name      : "superman"
  occupation: "crime fighting"
}

-- Pass
values = {
  1,2,3,4
  5,6,7,8
  name: "superman"
  occupation: "crime fighting"
}

P.S. 2: Destructuring also has this error

@leafo
Copy link
Owner

leafo commented Feb 20, 2019

This is an intentional syntax choice to avoid ambiguity:

  • hello: world{hello = world}
  • hello :worldhello({world = world})
  • hello : world → syntax error

Sorry I did not reply to this issue sooner

@ghost
Copy link
Author

ghost commented Feb 20, 2019

Oh, I see.
I'm closing the issue, thank you for your time.

@ghost ghost closed this as completed Feb 20, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant