Skip to content

Computed property ['__proto__'] not being assigned with defineProperty (T7223) #4188

Closed

Description

@babel-bot

Issue originally made by Andrew Bradley (cspotcode)

Bug information

  • Babel version: 6.6.5
  • Node version: 4.2.1
  • npm version: 2.14.7

Options

{
    "presets": ["es2015"]
}

Input code

require('assert');
var obj = {
  ['__proto__']: {'assigned with': 'assignment operator', bar: 'baz'},
  ['foo']: {'assigned with': 'defineProperty'}
};
assert(obj.bar === undefined);

Description

When an object literal sets a computed property "proto", it shouldn't modify the object's prototype. However, Babel is emitting code that does modify the prototype because it's not using defineProperty. This behavior seems to be unique to __proto__ since other computed properties properly use defineProperty.

https://babeljs.io/repl/#?evaluate=true&presets=es2015%2Cstage-2&experimental=false&loose=true&spec=false&playground=false&code=var%20a%20%3D%20%7B%0A%20%20%5B%22__proto__%22%5D%3A%20%7B%22assigned%20with%22%3A%20%22assignment%20operator%22%2C%20bar%3A%20'baz'%7D%2C%0A%20%20%5B%22foo%22%5D%3A%20%7B%22assigned%20with%22%3A%20%22defineProperty%22%7D%0A%7D%3B%0A%2F%2F%20should%20be%20undefined%2C%20but%20it's%20%22baz%22%0Aalert(a.bar)%3B&stage=0

Activity

  1. added
    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue
    on Apr 24, 2021
  2. locked as resolved and limited conversation to collaborators on Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions