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

Arrow functions fail to properly capture references to super #5784

Closed
ChadKillingsworth opened this issue Oct 15, 2018 · 2 comments
Closed

Comments

@ChadKillingsworth
Copy link

The following code will infinitely loop and alert "Child foo" in MS Edge. All other browsers seem to handle this correctly.

class Base {
  foo() {
    alert('base foo');
  }
}

class Child extends Base {
  foo() {
    const parent = () => super.foo;
    alert('Child foo');
    parent().call(this);
  }
}

(new Child()).foo();
@rhuanjl
Copy link
Collaborator

rhuanjl commented Oct 15, 2018

I had a quick look at the repro for this - seems to relate specifically to immediately returning the property accessed from super.

Case 1:

class Base { foo() { print('base foo'); } }

class Child extends Base {
  foo() {
    const parent = () => super.foo; // note using {return super.foo;} produced same result
    parent().call(this);
  }
}
new Child().foo();

eshost output:

#### JavaScriptCore, SpiderMonkey, V8 --harmony
base foo

#### Chakra, chDev
Error: Out of stack space

Case 2:

class Base { foo() { print('base foo'); } }

class Child extends Base {
  foo() {
    const parent = () => { const bar = super.foo; return bar; }
    parent().call(this);
  }
}

(new Child()).foo();

eshost output

#### Chakra, chDev, JavaScriptCore, SpiderMonkey, V8 --harmony
base foo

@boingoing
Copy link
Contributor

This has been fixed. Closing old issues.

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

No branches or pull requests

5 participants