<html>
<head>
<base href="https://bugs.webkit.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - [ESNext] Async iteration - Implement Async Generator"
href="https://bugs.webkit.org/show_bug.cgi?id=166695#c51">Comment # 51</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - [ESNext] Async iteration - Implement Async Generator"
href="https://bugs.webkit.org/show_bug.cgi?id=166695">bug 166695</a>
from <span class="vcard"><a class="email" href="mailto:caitp@igalia.com" title="Caitlin Potter (:caitp) <caitp@igalia.com>"> <span class="fn">Caitlin Potter (:caitp)</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=305500&action=diff" name="attach_305500" title="Patch">attachment 305500</a> <a href="attachment.cgi?id=305500&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=305500&action=review">https://bugs.webkit.org/attachment.cgi?id=305500&action=review</a>
<span class="quote">> Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js:117
> + } else {</span >
So the last thing is these handlers.
You could simplify this:
```
wrappedValue.@promise.@then(
function(result) {
const isDelegetedYield = generator.@asyncGeneratorSuspendReason === @AsyncGeneratorSuspendReasonDelegatedYield;
generator.@asyncGeneratorSuspendReason = @AsyncGeneratorSuspendReasonNone;
if (isDelegetedYield) {
const isDone = false;
@asyncGeneratorResolve(generator, result.value, isDone);
}
return @asyncGeneratorResumeNext(generator);
},
function(error) {
generator.@generatorState = @AsyncGeneratorStateCompleted; // see note below
@asyncGeneratorReject(generator, error);
@asyncGeneratorResumeNext(generator);
}
```
<span class="quote">> Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js:123
> + generator.@generatorState = @AsyncGeneratorStateCompleted;</span >
This actually looks wrong to me, per the current spec. Unless the committee decides to go with the "yielded rejections don't affect control flow of the generator" thing (which is admittedly pretty popular), closing the generator should be left up to @asyncGeneratorResume().
Even if the proposal is changed, this will prevent finally blocks from being reached.
E.g.
```js
let reject;
async function* foo() {
try {
yield new Promise(function(unused, rej) { reject = rej; });
} finally {
doImportantCleanupStuff(); // In this patch, this appears to be unreachable
return 0;
}
}
foo().next().then(x => print(x), e => print(e));
reject("Oop!");
```
I could be wrong about this, but I _believe_ this is broken in this patch due to the generator state change here, and I think it is supposed to work in the current spec</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>