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

Transpiling super does not handle assignment other than = #311

Open
overlookmotel opened this issue Nov 28, 2021 · 0 comments
Open

Transpiling super does not handle assignment other than = #311

overlookmotel opened this issue Nov 28, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@overlookmotel
Copy link
Owner

Input:

export default {
  foo() {
    super.x += 1;
  }
}.foo;

Output:

const super$0 = {},
  foo = (super$0 => ({
    foo() {
      Reflect.set(Object.getPrototypeOf(super$0), "x", 1, this);
    }
  }).foo)(super$0);
super$0.foo = foo;
export default foo;

Reflect.set(Object.getPrototypeOf(super$0), "x", 1, this) is equivalent to super.foo = 1 not += 1.

Also not handled:

  • super.foo &&= 1 (and other assignments)
  • super.foo++ / --super.foo
  • {x: super.foo} = {x: 1}
  • [super.foo] = [1]
  • for (super.foo of [1]) {}
  • for (super.foo in {x: 1}) {}

+=, &&= etc assignments will exhibit incorrect behavior. All other cases listed above will throw illegal assignment errors at run time.

@overlookmotel overlookmotel added the bug Something isn't working label Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant