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

Is inheritance supported? #16

Open
masuhar opened this issue May 1, 2018 · 2 comments
Open

Is inheritance supported? #16

masuhar opened this issue May 1, 2018 · 2 comments

Comments

@masuhar
Copy link
Contributor

masuhar commented May 1, 2018

With this code

class C { }
class D extends C {
    constructor() {}
}
var v = new D()

I get an error Error?: |this| used uninitialized in D class constructor

image

It reminds me a restriction in Java, where you should write a call to the super-constructor at the beginning of a constructor. You are also not safe to access fields of this before finishing the call to the super-constructor.

@masuhar
Copy link
Contributor Author

masuhar commented Oct 23, 2024

The cause of the problem:

  1. in JS, it seems that a constructor of a subclass must call super() before using this.
  2. Kanon inserts checkpoints inside of a constructor that uses this.
  3. Hence the error.

But changing the class D to this won't help:

class D extends C {
  constructor(){ super(); }
}

Though this is a correct program, Kanon inserts checkpoints before super(), which violates the use of thiis before super().

@masuhar
Copy link
Contributor Author

masuhar commented Oct 23, 2024

Conclusion: we should fix the instrumentation algorithm to properly treat super calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant