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

get #x requires newline, not semicolon #1240

Open
bbrk24 opened this issue May 9, 2024 · 1 comment
Open

get #x requires newline, not semicolon #1240

bbrk24 opened this issue May 9, 2024 · 1 comment

Comments

@bbrk24
Copy link
Contributor

bbrk24 commented May 9, 2024

This compiles:

class Dummy
  #x: number
  get #x
  private set #x

This does not:

class Dummy
  #x: number
  get #x; private set #x
@edemaine
Copy link
Collaborator

edemaine commented May 10, 2024

Currently, ; private set #x is being treated as a body to the get. Example where this is more obvious (also with another bug — missing ; before return):

class Dummy
  #x: number
  get #x; set #x
---
class Dummy {
  #x: number
  get x() {; set(this.#x)return this.#x }
}

I agree this is a bit counterintuitive, but I'm trying to understand the general rule that's being violated. Perhaps a body of ; should be treated as complete?

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

2 participants