title: Detecting "returned promise only" status of an async function
body: <p>I have a situation like this:</p>
  
  <pre><code>async function thirdPartyCode(a) {
      if (a == ...) {
          return myPromiser(...)  // can allow and act on this
      }
      let b = await someoneElsesPromiserB(...)
      if (b == ...) {
          let c = await myPromiser(...)  // must error on this
          ...
      }
      let d = await someoneElsesPromiserD(...)
      let e = myPromiser(...)  // note no await
      return e  // can allow and act on this
  }
  </code></pre>
  
  <p>As the author of myPromiser() and caller of this thirdPartyCode(), I'd like to detect whether the myPromiser()'s promise is used as the returning promise of the async function.  This is the only legal way to use it <em>in this particular kind of async function's calling context</em>.  It cannot be awaited on, or have .then() clauses attached to it while it is inside this function.</p>
  
  <p>If there were a way to know "When is the body of an async function <em>actually</em> finished", that would be a wedge to solving it.</p>
  
  <p><em>(Note: The strange limitations in this question are a by-product of using the <a href="https://github.com/emscripten-core/emscripten/wiki/Emterpreter" rel="nofollow noreferrer">Emscripten Emterpreter</a>.  The limits may (?) need not apply when <a href="https://emscripten.org/docs/porting/pthreads.html" rel="nofollow noreferrer">simulated pthreads</a> are available via WebAssembly workers / SharedArrayBuffer / etc.  But those bleeding-edge browser features aren't enabled by default at time of writing...so this unusual desire comes from wanting a compatible subset of code to be legal.)</em></p>