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

Incorrect output from async-to-generator transform when nested async methods #7327

Open
overlookmotel opened this issue Nov 17, 2024 · 0 comments
Assignees
Labels
A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Comments

@overlookmotel
Copy link
Contributor

overlookmotel commented Nov 17, 2024

Input:

const outer = {
  value: 0,
  async method() {
    () => super.value;

    const inner = {
      value: 0,
      async method() {
        () => super.value;
      }
    };

    () => super.value;
  }
};

Desired output:

const outer = {
  value: 0,
  method() {
    var _superprop_getValue = () => super.value;

    return _asyncToGenerator(function* () {
      () => _superprop_getValue();

      const inner = {
        value: 0,
        method() {
          var _superprop_getValue2 = () => super.value;
          return _asyncToGenerator(function* () {
            () => _superprop_getValue2();
          })();
        }
      };

      () => _superprop_getValue();
    })();
  }
};

Actual output:

const outer = {
  value: 0,
  method() {
    var _superprop_getValue3 = () => super.value;

    return _asyncToGenerator(function* () {
      // OOPS! `_superprop_getValue` doesn't exist
      () => _superprop_getValue();

      const inner = {
        value: 0,
        method() {
          var _superprop_getValue2 = () => super.value;
          return _asyncToGenerator(function* () {
            () => _superprop_getValue2();
          })();
        }
      };

      () => _superprop_getValue3();
    })();
  }
};

I believe that when exiting a function which has super bindings, need to restore previous state of super_methods. It probably needs to be a stack.

Babel REPL

Failing test: #7314

@overlookmotel overlookmotel added C-bug Category - Bug A-transformer Area - Transformer / Transpiler labels Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transformer Area - Transformer / Transpiler C-bug Category - Bug
Projects
None yet
Development

No branches or pull requests

2 participants