tc39 / proposal-class-public-fields

Stage 2 proposal for public class fields in ECMAScript
https://tc39.github.io/proposal-class-public-fields/
487 stars 25 forks source link

Add early error for static 'prototype' fields #47

Closed bakkot closed 7 years ago

bakkot commented 8 years ago

In current code, it is an early error to declare a static method statically named 'prototype'. (It's a runtime error if the name is computed, since evaluating the class definition will attempt to overwrite the non-configurable 'prototype' property of the constructor.)

Since static fields are likewise installed as properties of the constructor, static fields should have the same restriction. That is, this should be an early error:

class C {
  static prototype = 0;
}

This PR accomplishes this.

michaelficarra commented 8 years ago

Nice catch.