<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#c6">Comment # 6</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:gskachkov&#64;gmail.com" title="GSkachkov &lt;gskachkov&#64;gmail.com&gt;"> <span class="fn">GSkachkov</span></a>
</span></b>
        <pre>Comment on <span class="bz_obsolete"><a href="attachment.cgi?id=298142&amp;action=diff" name="attach_298142" title="Patch">attachment 298142</a> <a href="attachment.cgi?id=298142&amp;action=edit" title="Patch">[details]</a></span>
Patch

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

<span class="quote">&gt;&gt;&gt; Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js:39
&gt;&gt;&gt; +        &#64;throwTypeError(&quot;Async generator is executing&quot;);
&gt;&gt; 
&gt;&gt; Async Generators differ from ordinary generators, in that it's not an error to resume the generator while it's executing.
&gt;&gt; 
&gt;&gt; While it's an unlikely case, the generator is allowed to queue up additional requests while executing, and the queue of requests is drained during resumption (the proposal words this as recursive calls from AsyncGeneratorResolve / AsyncGeneratorReject -&gt; AsyncGeneratorResumeNext)
&gt; 
&gt; Sure I'll remove this line.
&gt; I've tried to replace queue by chain of promises to allow invoke 'next' many times as well. Also I have not implement&amp;tests methods 'return' &amp; 'throw', not sure that they work correct in this patch.</span >

I read spec one more time and it seems that implementation of 'AsyncGenerator Abstract Operations'  with AsyncGeneratorResolve / AsyncGeneratorReject -&gt; AsyncGeneratorResumeNext will require some additional changes in 'generator' and 'async function', so I decided that it should be not be part of this patch, and be part of the separate task - <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ESNext] Async iteration - Implement Async Generator runtime in specification compliance"
   href="show_bug.cgi?id=166848">https://bugs.webkit.org/show_bug.cgi?id=166848</a>

<span class="quote">&gt;&gt;&gt;&gt; Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js:65
&gt;&gt;&gt;&gt; +    if (generator.&#64;asyncGeneratorState === &#64;AsyncGeneratorStateAwait) {
&gt;&gt;&gt; 
&gt;&gt;&gt; the special generator continuation is a nice idea.
&gt;&gt;&gt; 
&gt;&gt;&gt; Though it doesn't affect JSC just yet due to not being implemented, note that this would _probably_ be observable via the function.sent metaproperty (or at least, it is in the v8 generator implementation without some additional work).
&gt;&gt; 
&gt;&gt; Oh Sorry, not sure that I got it. 
&gt;&gt; Do you mean that in case of using chain of promises instead of queue, we will have visible side effects when function.sent would be implemented?
&gt;&gt; Could you please provide some examples that you faced in v8? I'll try to emulate on current solution, possible current approach is not viable at all.
&gt;&gt; 
&gt;&gt; Also it seems that I need to replace this by: 
&gt;&gt; 
&gt;&gt;         let wrappedValue = &#64;newPromiseCapability(&#64;Promise);
&gt;&gt;         wrappedValue.&#64;resolve.&#64;call(&#64;undefined, value);
&gt;&gt;         wrappedValue.&#64;promise.&#64;then(
&gt;&gt;                                     function(result) { &#64;asyncGeneratorResume(generator, promiseCapability, result, &#64;GeneratorResumeModeNormal); },
&gt;&gt;                                     function(error) { &#64;asyncGeneratorResume(generator, promiseCapability, error, &#64;GeneratorResumeModeThrow); });
&gt;&gt; Because value is returned by await can be non promise value.
&gt; 
&gt; What I was getting at was about the `function.sent` metaproperty proposal (<a href="https://github.com/allenwb/ESideas/blob/master/Generator%20metaproperty.md">https://github.com/allenwb/ESideas/blob/master/Generator%20metaproperty.md</a>), which allows the programmer to make `function.sent` an alias to the value the generator was resumed with (eg `generator.next(&quot;foo&quot;);` makes function.sent === &quot;foo&quot; inside the generator after resuming).
&gt; 
&gt; So, with Async Generators and await expressions, the awaited value would alias function.sent rather than the value sent via generator.next(), which observably breaks the metaproperty.
&gt; 
&gt; JSC does not implement function.sent yet, so it isn't really noticeable here, but it is something to pay attention to for the future, unless the proposal is withdrawn</span >

OK. I'll keep in mind. Thanks for information.</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>