Skip to content

InlineSimpleMethods makes a semantic change in ES2015+ #3756

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

Closed
DavidANeil opened this issue Jan 16, 2021 · 1 comment · Fixed by #3757
Closed

InlineSimpleMethods makes a semantic change in ES2015+ #3756

DavidANeil opened this issue Jan 16, 2021 · 1 comment · Fixed by #3757
Assignees

Comments

@DavidANeil
Copy link
Contributor

Given the following input code:

class Holder {
    constructor() {
        this.val = {internal: true};
        this.context =  {getVal: () => this.val}
    }
}

console.log(new Holder().context.getVal().internal);

Outputs:

class a {
  constructor() {
    this.g = {h:!0};
    this.i = {j:() => this.g};
  }
}
console.log((new a).i.g.h);

The InlineSimpleMethods replaces the call of getVal() with val, which is incorrect because the this in the definition of getVal is not context, but rather Holder.
This is not a problem in ES5, because the arrow function is already rewritten before running this pass.

@blickly
Copy link
Contributor

blickly commented Jan 21, 2021

Wow, thanks for the nice simple repro case!

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

Successfully merging a pull request may close this issue.

2 participants