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

`await` doesn't work in `for..let` loops #1021

Closed
pepkin88 opened this issue Mar 22, 2018 · 1 comment
Closed

`await` doesn't work in `for..let` loops #1021

pepkin88 opened this issue Mar 22, 2018 · 1 comment
Labels
bug

Comments

@pepkin88
Copy link
Contributor

@pepkin88 pepkin88 commented Mar 22, 2018

Example:

fn = ->>
  for let v in [Promise.resolve 1]
    await v

Result:

var fn;
fn = async function(){
  var i$, ref$, len$, results$ = [], fn$ = function*(v){
    return (await v);
  };
  for (i$ = 0, len$ = (ref$ = [Promise.resolve(1)]).length; i$ < len$; ++i$) {
    results$.push((yield* (fn$.call(this, ref$[i$]))));
  }
  return results$;
};

Expected result:

var fn;
fn = async function(){
  var i$, ref$, len$, results$ = [], fn$ = async function(v){
    return (await v);
  };
  for (i$ = 0, len$ = (ref$ = [Promise.resolve(1)]).length; i$ < len$; ++i$) {
    results$.push((await (fn$.call(this, ref$[i$]))));
  }
  return results$;
};

It seems the mechanism for yields is also used for awaits, but those require a special treatment.

I also noticed that asynchronous generator functions are not yet supported, so I couldn't test for that.

@rhendric
Copy link
Collaborator

@rhendric rhendric commented Mar 22, 2018

Good news: fixing #1019 will also fix this! (At least, the proof of concept fix I wrote for #1019 to make sure that it would be a good tutorial bug fixes this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants