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

Comments

Projects
None yet
2 participants
@pepkin88
Contributor

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

This comment has been minimized.

Collaborator

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