Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[builtins - Object] Object.getPrototypeOf returning incorrectly #532

Closed
croraf opened this issue Jun 27, 2020 · 1 comment · Fixed by #642
Closed

[builtins - Object] Object.getPrototypeOf returning incorrectly #532

croraf opened this issue Jun 27, 2020 · 1 comment · Fixed by #642
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution
Milestone

Comments

@croraf
Copy link
Contributor

croraf commented Jun 27, 2020

To Reproduce

const c = function a (){};
const d = new c();

Object.getPrototypeOf(d)

Expected behavior
Should return the prototype object whose constructor field points to function a(){}.

undefined is returned instead.

@croraf croraf added the bug Something isn't working label Jun 27, 2020
@croraf croraf changed the title [builtins - Object] Object.getPrototype of returning incorrectly [builtins - Object] Object.getPrototypeOf returning incorrectly Jun 27, 2020
@croraf
Copy link
Contributor Author

croraf commented Jun 27, 2020

Seems that this is caused by the fact that the following gives undefined:

const c = function a (){};
const d = new c();

d.__proto__;

Checking the code it seems that d.__proto__ during construction is set to c.prototype. And c.prototype outputs this object:

{
  __proto__: {
    constructor: {
      setPrototypeOf: {
        length: 2
      },
      prototype: [Cycle],
        name: Object,
          length: 1,
            defineProperty: {
        length: 3
      },
      getPrototypeOf: {
        length: 1
      },
      is: {
        length: 2
      },
      __proto__: {
        constructor: {
          name: Function,
            prototype: [Cycle],
              length: 1,
                __proto__: undefined
        },
        __proto__: undefined
      }
    },
    hasOwnProperty: {
      length: 0
    },
    propertyIsEnumerable: {
      length: 0
    },
    toString: {
      length: 0
    }
  }
}

EDIT: c.prototype seems to be wrong. It only has the __proto__ property, but it should also have the constructor property pointing to the function a.

@54k1 54k1 mentioned this issue Aug 18, 2020
@Razican Razican added builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels Aug 19, 2020
@Razican Razican added this to the v0.10.0 milestone Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants