Repository navigation
fix: do not make __proto__ setters computed - #18602
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63387 |
|
commit: |
53e7f05 to
11df694
Compare
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Can you add a test with a duplicate proto setter? Do old browsers for which this plugin is needed have problems with that?
Goode question. Old browsers, such as V8 3.14 and 3.28, used by Node.js 0.10 and 0.12 respectively, counts ({
get __proto__() {},
["__proto__"]: p
})which does not throw but changed the semantics. Currently, we keep the input as-is, semantics is correct but the old engines would not support it. I will push a new commit and make the other ({
get ["__proto__"]() {},
__proto__: p
})so the output should work on older engines. Aside: we should revive another PR that allows us to run exec tests on older engines, such as Node.js 0.10 and 0.12. |
2c86018 to
5c54b80
Compare
`{ __proto__() {}, __proto__: p }` is not a duplicate: the second property sets the prototype and does not define a property.
Previously the second property was rewritten to `["__proto__"]: p`, which defines an own property named "__proto__" and leaves the prototype untouched.
Assisted-by: Claude Fable 5.2
…a proto setter
ES5 engines count `__proto__: value` as a data property named "__proto__"
in the duplicate property checks, so `{ get __proto__() {}, __proto__: p }`
is a SyntaxError there even in sloppy mode (tested on V8 3.14 and 3.28).
When an object literal has a `__proto__: value` property, every other
non-computed property named "__proto__" is now made computed, whatever
the order, so that the proto setter keeps setting the prototype.
Assisted-by: Claude Opus 5.5
5c54b80 to
0ead329
Compare
|
Backported to 7.x in #18646. |
{ __proto__() {}, __proto__: p }is not a duplicate: the second property sets the prototype and does not define a property.Previously the second property was rewritten to
["__proto__"]: p, which defines an own property named "proto" and leaves the prototype untouched.Assisted-by: Claude Fable 5.2