tree-sitter-javascript
tree-sitter-javascript copied to clipboard
Static class initialization block
The following piece of code is valid but it is parsed incorrectly:
The random parsing seems to be a combination of export
, static
class initialization block and comments.
export class Incorrect {
static {
this.foo = true
this.bar = false
this.hello = 1
this.init()
}
}
export class Incorrect {
static {
this.foo= true
this.bar = false
this.init()
this.hello = 1
}
}
export class Correct {
static {
this.foo= true
this.bar = false
this.init()
this.hello = 1
}
}
export class Incorrect {
static {
// This comment affects parsing
this.foo= true
this.bar = false
this.init()
this.hello = 1
}
}
// This comment affects parsing
export class Incorrect {
static {
this.foo= true
this.bar = false
this.init()
this.hello = 1
}
}
Functions call only
export class Incorrect {
static {
this.init()
this.init()
this.init()
}
}
export class Incorrect {
static {
this.init()
this.init()
this.init()
}
}
export class Incorrect {
static {
// This comment affects parsing
this.init()
this.init()
this.init()
}
}
// This comment does not affects parsing (which is already incorrect)
export class Incorrect {
static {
this.init()
this.init()
this.init()
}
}
Functions call only no export
class Incorrect {
static {
this.init()
this.init()
this.init()
}
}
class Correct {
static {
this.init()
this.init()
this.init()
}
}
class Incorrect {
static {
// This comment does not affects parsing (which is already incorrect)
this.init()
this.init()
this.init()
}
}
// This comment does not affects parsing (which is already incorrect)
class Incorrect {
static {
this.init()
this.init()
this.init()
}
}
Can you drop a link to where this language feature is described in the spec, or somewhere official?
https://tc39.es/ecma262/multipage/ecmascript-language-functions-and-classes.html#prod-ClassStaticBlock
You closed the issue, I assumed it was solved but may you explain why the parsing is still incorrect on my initial post?