DanielXMoore / Civet

A TypeScript superset that favors more types and less typing
https://civet.dev
MIT License
1.33k stars 28 forks source link

`get #x` requires newline, not semicolon #1240

Open bbrk24 opened 1 month ago

bbrk24 commented 1 month ago

This compiles:

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

This does not:

class Dummy
  #x: number
  get #x; private set #x
edemaine commented 1 month ago

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?