Skip to content

Static class initialization block #222

@madmoizo

Description

@madmoizo

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()
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions