Reject __proto__ as the JavaScript name of a field
Why
In JavaScript, __proto__ is an accessor every object inherits from Object.prototype, not a plain key. A record field with that name is written through the setter (#9457) and, when absent, reads the prototype, and every code path that builds a record needs its own workaround. The type checker now rejects the name (#9512).
addedDiagnostic __proto__ field name
type t = {name: string, @as("__proto__") parent?: int}diagnostic
A field's JavaScript name can't be __proto__: in JavaScript, it sets the object's prototype instead of a property. Use another name, or a dict.The check covers record and inline-record labels, plain or renamed with @as, object-type fields (including those @obj externals generate) and @tag. Object literals without a type annotation and dict literals keep printing a "__proto__" key as a computed key.
Review
- Why does the record spread lose its Object.defineProperty branch? It only ran for a field named __proto__, which can't be declared any more, so no program that compiles changes its output.