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] Rest parameters with async bug #1001

Open
bluesign opened this issue Sep 18, 2022 · 0 comments
Open

[Transpiling] Rest parameters with async bug #1001

bluesign opened this issue Sep 18, 2022 · 0 comments

Comments

@bluesign
Copy link

bluesign commented Sep 18, 2022

Minimal test case:

export const brokenArgsRest = async (...props) => {
  await someAsyncFunction(async () => {  
      console.log(props)
  })
}

export const someAsyncFunction = async callback => {
  await callback()
}

generates

var brokenArgsRest = function brokenArgsRest() {
  return Promise.resolve(someAsyncFunction(function () {
    try {
      var _arguments2 = arguments;
      console.log([].slice.call(_arguments2));
      return Promise.resolve();
    } catch (e) {
      return Promise.reject(e);
    }
  })).then(function () {});
};
var someAsyncFunction = function someAsyncFunction(callback) {
  try {
    return Promise.resolve(callback()).then(function () {});
  } catch (e) {
    return Promise.reject(e);
  }
};

var _arguments2 = arguments; should be one more level up

Context:
We hit this bug on fcl-js lib : onflow/flow-js-testing#182

PS: my js knowledge is limited, but seems related to inlining somehow.

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

No branches or pull requests

1 participant