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

Require commas after all but the last field assignment in class literals #562

Closed
yorickpeterse opened this issue May 30, 2023 · 0 comments
Closed
Assignees
Labels
bug Defects, unintended behaviour, etc compiler Changes related to the compiler
Milestone

Comments

@yorickpeterse
Copy link
Collaborator

Please describe the bug

While taking a look at https://github.com/dusty-phillips/inko-http/ I noticed that we don't error for code like this:

SomeClass {
  @field1 = value1
  @field2 = value2
}

We shouldn't allow this as it can lead to unclear syntax and potentially result in the parser parsing things differently. For example, I'm not sure what happens with code like this:

SomeClass {
  @field1 = value1 @field2 = value2
}

To resolve this, we should just require a comma after every assignment, except for the last assignment (i.e. no comma is needed if the next character is }).

Please list the exact steps necessary to reproduce the bug

Create test.inko with these contents:

class Foo {
  let @a: Int
  let @b: Int
}

class async Main {
  fn async main {
    Foo {
      @a = 10
      @b = 20
    }
  }
}

Then run inko check test.inko. This should fail with a parser error, but it doesn't.

Operating system

Fedora Silverblue 38

Inko version

main

Rust version

1.68.2

@yorickpeterse yorickpeterse added bug Defects, unintended behaviour, etc compiler Changes related to the compiler labels May 30, 2023
@yorickpeterse yorickpeterse added this to the 0.13.0 milestone May 30, 2023
@yorickpeterse yorickpeterse modified the milestones: 0.13.0, 0.14.0 Jun 6, 2023
@yorickpeterse yorickpeterse self-assigned this Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects, unintended behaviour, etc compiler Changes related to the compiler
Projects
None yet
Development

No branches or pull requests

1 participant