Civet
Civet copied to clipboard
yield in do
What should yield mean inside a do expression/block? The TC39 proposal says that it should yield in the containing function. We already support this with await but don't for yield.
For comparison, the Babel plugin for this proposal (main source code) supports this feature, and suggests a transpilation: just add yield* before the IIFE.
We should match TC39 on this.
f = (x) ->
y := do
await x
A better transpilation for us would be something like:
f = async function (x) {
let ref;
{
ref = await x
}
const y = ref;
return y;
};
Similarly for yield:
f = (x) ->
y := do
yield x
f = function* (x) {
let ref;
{
ref = yield x
}
const y = ref;
return y;
};
This ties in with removing IIFEs as much as possible as mentioned in some other issues.
I agree that we should do that long term. (#202 and #381 are two of the relevant issues. I've added yield to the title of #202.) But in the short term we can fix this case easily via yield*, so we should do that.