<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&#64;igalia.com" title="Caitlin Potter (:caitp) &lt;caitp&#64;igalia.com&gt;"> <span class="fn">Caitlin Potter (:caitp)</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=305500&amp;action=diff" name="attach_305500" title="Patch">attachment 305500</a> <a href="attachment.cgi?id=305500&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=305500&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=305500&amp;action=review</a>

<span class="quote">&gt; Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js:117
&gt; +                                        } else {</span >

So the last thing is these handlers.

You could simplify this:

```
wrappedValue.&#64;promise.&#64;then(
    function(result) {
        const isDelegetedYield = generator.&#64;asyncGeneratorSuspendReason === &#64;AsyncGeneratorSuspendReasonDelegatedYield;
        generator.&#64;asyncGeneratorSuspendReason = &#64;AsyncGeneratorSuspendReasonNone;
        if (isDelegetedYield) {
            const isDone = false;
            &#64;asyncGeneratorResolve(generator, result.value, isDone);
        }
        return &#64;asyncGeneratorResumeNext(generator);
    },
    function(error) {
        generator.&#64;generatorState = &#64;AsyncGeneratorStateCompleted; // see note below
        &#64;asyncGeneratorReject(generator, error);
        &#64;asyncGeneratorResumeNext(generator);
    }
```

<span class="quote">&gt; Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js:123
&gt; +                                        generator.&#64;generatorState = &#64;AsyncGeneratorStateCompleted;</span >

This actually looks wrong to me, per the current spec. Unless the committee decides to go with the &quot;yielded rejections don't affect control flow of the generator&quot; thing (which is admittedly pretty popular), closing the generator should be left up to &#64;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 =&gt; print(x), e =&gt; print(e));
reject(&quot;Oop!&quot;);
```

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>