ecma262
ecma262 copied to clipboard
editorial: mismatch between `Await` transfer-of-control and `AsyncBlockStart`
AsyncBlockStart step 5 transfers control into an async function, which (unless it completes without await
ing) transfers it back by hitting Await step 10.
But Await step 10 resumes the outer context with ~empty~
, and AsyncBlockStart step 7 asserts that it has been resumed with NormalCompletion(~unused~)
. They should match. And specifically it needs to be a normal completion because the abstract closure crated by NewPromiseReactionJob generally returns completion records.
I believe we introduced this mismatch in https://github.com/tc39/ecma262/pull/2665: prior to that PR Await would Return NormalCompletion(~unused~)
, and subsequently it would Resume _callerContext_ passing ~empty~
.
Also, we could maybe stand to give more details about where control transfers of this kind can go. It's nice that AsyncBlockStart mentions the two possible places it can be resumed from, though it could stand to mention the relevant step of Await, not merely name the AO. Also, Await could mention that it returns either to AsyncBlockStart or, in the case of await
s after the first, is returning to the host steps which triggered it to run after the previous await
(e.g. in HTML). The generator machinery is slightly simpler but could also benefit from such notes.