{"action":"created","issue":{"url":"https://api.github.com/repos/lukehoban/ecmascript-asyncawait/issues/35","labels_url":"https://api.github.com/repos/lukehoban/ecmascript-asyncawait/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/lukehoban/ecmascript-asyncawait/issues/35/comments","events_url":"https://api.github.com/repos/lukehoban/ecmascript-asyncawait/issues/35/events","html_url":"https://github.com/lukehoban/ecmascript-asyncawait/issues/35","id":60242178,"number":35,"title":"What happens when an exception is thrown from a parameter initializer?","user":{"login":"zenparsing","id":5995084,"avatar_url":"https://avatars.githubusercontent.com/u/5995084?v=3","gravatar_id":"","url":"https://api.github.com/users/zenparsing","html_url":"https://github.com/zenparsing","followers_url":"https://api.github.com/users/zenparsing/followers","following_url":"https://api.github.com/users/zenparsing/following{/other_user}","gists_url":"https://api.github.com/users/zenparsing/gists{/gist_id}","starred_url":"https://api.github.com/users/zenparsing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenparsing/subscriptions","organizations_url":"https://api.github.com/users/zenparsing/orgs","repos_url":"https://api.github.com/users/zenparsing/repos","events_url":"https://api.github.com/users/zenparsing/events{/privacy}","received_events_url":"https://api.github.com/users/zenparsing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-08T05:25:13Z","updated_at":"2015-03-13T22:32:58Z","closed_at":null,"body":"If an exception is thrown during evaluation of a parameter default initializer, does it result in an exception, or a rejected promise?\r\n\r\n```js\r\nasync function f(a = (null).x) {}\r\nf();  // Exception or rejection?\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/lukehoban/ecmascript-asyncawait/issues/comments/79492043","html_url":"https://github.com/lukehoban/ecmascript-asyncawait/issues/35#issuecomment-79492043","issue_url":"https://api.github.com/repos/lukehoban/ecmascript-asyncawait/issues/35","id":79492043,"user":{"login":"lukehoban","id":223467,"avatar_url":"https://avatars.githubusercontent.com/u/223467?v=3","gravatar_id":"","url":"https://api.github.com/users/lukehoban","html_url":"https://github.com/lukehoban","followers_url":"https://api.github.com/users/lukehoban/followers","following_url":"https://api.github.com/users/lukehoban/following{/other_user}","gists_url":"https://api.github.com/users/lukehoban/gists{/gist_id}","starred_url":"https://api.github.com/users/lukehoban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukehoban/subscriptions","organizations_url":"https://api.github.com/users/lukehoban/orgs","repos_url":"https://api.github.com/users/lukehoban/repos","events_url":"https://api.github.com/users/lukehoban/events{/privacy}","received_events_url":"https://api.github.com/users/lukehoban/received_events","type":"User","site_admin":false},"created_at":"2015-03-13T22:32:58Z","updated_at":"2015-03-13T22:32:58Z","body":"@zenparsing Totally agree on the reason for wanting this to return a rejected promise.  I'd argue there's a similar reason to want generators to do the equivalent:\r\n\r\n```JavaScript\r\nfunction* f(a = (null).x) {}\r\nvar x = f(); // do I get an exception here?\r\nx.next(); // or here?\r\n```\r\n\r\nAny exception thrown within the body of the generator won't throw till the call to `next`, so for the most part I never have to worry about exceptions thrown out of the invocation of the generator function.  Except that apparently parameter default expressions are evaluated in a context that can throw out of the generator function invocation.\r\n\r\nOf course, this is somewhat more painful to workaround for async/await.\r\n\r\nUnfortunately, I don't think there is any way to spec/implement async/await with this semantics on top of generators assuming they intentionally have a different semantics.\r\n\r\nI was really hoping that async/await would not have to invent any new semantics - it would just be pure sugar over generators + Promises."}}