Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Fix static property parse regression. [closes #804]
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed May 16, 2019
1 parent a2b7949 commit 51c217b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
15 changes: 15 additions & 0 deletions src/acorn/parser/class-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ function init() {
}

if (this.isContextual("static")) {
if (nextType === tt.star) {
return Reflect.apply(func, this, args)
}

const nextNextType = lookahead(next).type

if (nextNextType !== tt.braceR &&
nextNextType !== tt.eq &&
nextNextType !== tt.semi &&
(next.isContextual("async") ||
next.isContextual("get") ||
next.isContextual("set"))) {
return Reflect.apply(func, this, args)
}

next.parsePropertyName(this.startNode())

if (next.type === tt.parenL) {
Expand Down
42 changes: 21 additions & 21 deletions test/compiler-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -393,27 +393,27 @@ describe("compiler tests", () => {
it("should parse class fields syntax", () => {
const code = [
"export class A { a }",
"export class B { b = 1 }",
"export class C { [c] }",
"export class D { [d] = 1 }",
"export class E { static e }",
"export class F { static f = 1 }",
"export class G { static [g] }",
"export class H { static [h] = 1 }",
"export class I { #i }",
"export class J { static #j }",
"export class K { static #k = 1 }",
"export class L { async }",
"export class M { get }",
"export class N { set }",
"export class O { static }",
"export class P {",
' #p = "p"',
" p() {",
" return this.#p",
" }",
"}",
"export class Q {",
"export class B { [b] }",
"export class C { static c }",
"export class D { static [d] }",
"export class E { #e }",
"export class F { static #f }",
"export class G { async }",
"export class H { get }",
"export class I { set }",
"export class J { static }",
"export class K {",
" a = 1",
" [b] = 1",
" static c = 1",
" static [d] = 1",
" static #e = 1",
" e() { this.#e }",
" static get f() {}",
" static set f(v) {}",
" static async g() {}",
" static *h() {}",
" static async *i() {}",
" async = 1;",
" get = 1",
" set = 1",
Expand Down

0 comments on commit 51c217b

Please sign in to comment.