Skip to content

Native Class Inheritance Issue #10915

Closed
Closed

Description

@cbratschi
  • Version: v6.9.1
  • Platform: macOS (Darwin)
  • Subsystem: v8

A native v8 class is extended on the JavaScript side and new methods are added. However, those methods cannot be called in the newly created instance: they are undefined. Something seems to be wrong with the prototype chain. It also fails if the older prototyping syntax is being used.

The issue is reproducible on Node.js v.6.9.1. Node v4.x and v7.0.0 are not affected.

Sample code:

https://github.com/cbratschi/aminogfx-gl/blob/master/demos/tests/js.js

/**
 * Extend AminoGfx Class.
 */
class Circle extends Polygon {
   constructor(amino) {
       super(amino);

       console.log('Circle: constructor');

       /*
        * Issues:
        *
        *   - Node v6.9.1
        *     - TypeError: this.setup is not a function
        *
        * Works fine:
        *
        *   - Node v4.x
        *   - Node v7.0.0
        */
       this.setup();
   }

   setup() {
       console.log('Circle.setup()');
   }
}

Polygon is the native class.

Activity

  1. added
    duplicateIssues and PRs that are duplicates of other issues or PRs.
    v8 engineIssues and PRs related to the V8 dependency.
    on Jan 20, 2017
  2. addaleax commented on Jan 20, 2017

    @addaleax
    Member

    This seems to be a duplicate of #9288. You can subscribe to that thread and #9293 (the PR that would fix this in v6.x, if it works at some point) to stay up to date.

    I’m closing this as a duplicate but feel free to ask follow-up questions if there are any.

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

    duplicateIssues and PRs that are duplicates of other issues or PRs.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions