16:48
<devsnek>
mfw `return promise` can throw in async generators but not async functions
17:32
<ljharb>
devsnek: example?
17:32
<devsnek>
ljharb: `return Promise.reject()`
17:33
<ljharb>
why would that throw
17:33
<devsnek>
`return` performs an await in async generators
17:33
<devsnek>
https://gc.gy/56923403.png
17:34
<Bakkot>
yeah that's pretty weird
17:35
<Bakkot>
otoh does anyone actually `return` in a generator?
17:35
<devsnek>
i do
17:35
<devsnek>
but its not that common
17:35
<Bakkot>
why?
17:35
<Bakkot>
(sincerely; I'm curious what the use case is)
17:35
<devsnek>
my engine262 evaluator is built on generators
17:35
<devsnek>
not the async kind though
17:36
<ljharb>
yes that is very weird
17:36
<devsnek>
Bakkot: https://github.com/engine262/engine262/blob/parser/src/runtime-semantics/IfStatement.mjs#L21
17:36
<Bakkot>
what does `return` do for you there?
17:36
<devsnek>
its how i return values
17:37
<devsnek>
i use it like a normal return
17:37
<Bakkot>
hmm
17:37
<Bakkot>
I guess my question is, presumably this bottoms out somewhere where it isn't just generators deferring to generators
17:37
<Bakkot>
and that is the part I am interested in
17:37
<devsnek>
https://github.com/engine262/engine262/blob/parser/src/helpers.mjs#L141-L153
17:38
<devsnek>
https://github.com/engine262/engine262/blob/parser/src/abstract-ops/function-operations.mjs
17:39
<devsnek>
oops
17:39
<devsnek>
https://github.com/engine262/engine262/blob/parser/src/abstract-ops/function-operations.mjs#L124-L127
17:39
<Bakkot>
aha
17:39
<Bakkot>
neat