Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Linebreaks after 'get' or 'set' in class bodies are not parsed correctly (T7533) #157

Closed
motiz88 opened this issue Oct 5, 2016 · 3 comments
Labels

Comments

@motiz88
Copy link
Contributor

motiz88 commented Oct 5, 2016

Issue originally made by @bakkot (as T7533 and later babel/babel#4432)

Input code

class A {
  get
    x(){}
}

Description

This code gives a parse error without the class-properties-transform plugin, and is parsed as a class containing a single method x with it. Neither is correct; it's valid syntax for a class with a getter (not method) for 'x'.

@motiz88
Copy link
Contributor Author

motiz88 commented Oct 5, 2016

All parsers on ast-explorer.net, except for TypeScript, disagree with Babylon's parse here.

@bakkot
Copy link
Contributor

bakkot commented Oct 9, 2016

The issue is larger than I initially reported. All of the following are incorrectly rejected:

class C {
  x
  (){}
}
class C {
  ''
  (){}
}
class C {
  ['']
  (){}
}
class C {
  get
  (){}
}
class C {
  set
  (){}
}
class C {
  static
  (){}
}
class C {
  async
  (){}
}

etc., which define methods named 'x', '', 'get', 'set', 'static', or 'async'.

@danez
Copy link
Member

danez commented Jun 3, 2017

Fixed as of 6.17.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants