{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/67","labels_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/67/comments","events_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/67/events","html_url":"https://github.com/tc39/ecmascript-asyncawait/issues/67","id":109826631,"number":67,"title":"How do I await on an async function returned by await?","user":{"login":"matAtWork","id":9590115,"avatar_url":"https://avatars.githubusercontent.com/u/9590115?v=3","gravatar_id":"","url":"https://api.github.com/users/matAtWork","html_url":"https://github.com/matAtWork","followers_url":"https://api.github.com/users/matAtWork/followers","following_url":"https://api.github.com/users/matAtWork/following{/other_user}","gists_url":"https://api.github.com/users/matAtWork/gists{/gist_id}","starred_url":"https://api.github.com/users/matAtWork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matAtWork/subscriptions","organizations_url":"https://api.github.com/users/matAtWork/orgs","repos_url":"https://api.github.com/users/matAtWork/repos","events_url":"https://api.github.com/users/matAtWork/events{/privacy}","received_events_url":"https://api.github.com/users/matAtWork/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-05T15:47:12Z","updated_at":"2015-10-05T15:49:52Z","closed_at":null,"body":"I've possibly (probably?) misunderstood either the precedence issues or contexts in which await is a keyword rather than a possible identifier, but clarification would be good.\r\n\r\nThis is from an issue at https://github.com/marijnh/acorn/issues/309\r\n\r\n````\r\n// Return an async function asynchronously\r\nasync function x(n) {\r\n    return async function xxx(m) { return n+m }\r\n}\r\n\r\nasync function test() {\r\n    var r = await x(\"a\") ;\r\n    console.log(r) ;        // [Function: xxx] - correct\r\n    console.log(await r(\"b\")) ; // \"ab\" - correct\r\n    console.log(await (await x(\"c\"))(\"d\")) ;    // [ReferenceError: await is not defined] - fail! await() looks like a call\r\n    console.log(await await x(\"e\")(\"f\")) ;  // Fail! x(\"e\")(\"f\") binds to second await and fails (not a Promise)\r\n}\r\n\r\ntest().then(console.log.bind(console),console.error.bind(console)) ;\r\n````"},"comment":{"url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/comments/145577140","html_url":"https://github.com/tc39/ecmascript-asyncawait/issues/67#issuecomment-145577140","issue_url":"https://api.github.com/repos/tc39/ecmascript-asyncawait/issues/67","id":145577140,"user":{"login":"sebmck","id":853712,"avatar_url":"https://avatars.githubusercontent.com/u/853712?v=3","gravatar_id":"","url":"https://api.github.com/users/sebmck","html_url":"https://github.com/sebmck","followers_url":"https://api.github.com/users/sebmck/followers","following_url":"https://api.github.com/users/sebmck/following{/other_user}","gists_url":"https://api.github.com/users/sebmck/gists{/gist_id}","starred_url":"https://api.github.com/users/sebmck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebmck/subscriptions","organizations_url":"https://api.github.com/users/sebmck/orgs","repos_url":"https://api.github.com/users/sebmck/repos","events_url":"https://api.github.com/users/sebmck/events{/privacy}","received_events_url":"https://api.github.com/users/sebmck/received_events","type":"User","site_admin":false},"created_at":"2015-10-05T15:49:52Z","updated_at":"2015-10-05T15:49:52Z","body":"`await` is a keyword inside of an async function and the argument is parsed with the precedence of a `UnaryExpression`."}}