Skip to content

InlineSimpleMethods makes a semantic change in ES2015+ #3756

Closed
@DavidANeil

Description

@DavidANeil

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions