I wanted a macro that takes a sub-generator and yields its elements. I wrote this:
macro yieldmany(resumable::Expr)
return quote
for x in $(esc(resumable))
@yield x
end
end
end
However, when I use it in a function, I get an error:
@resumable function F2()
@yield 2
@yieldmany F1()
@yield 4
end
ERROR: LoadError: LoadError: @yield macro outside a @resumable function!
I tried using macroexpand to see what it's making, but I get the same error:
@macroexpand @yieldmany F1()
ERROR: LoadError: @yield macro outside a @resumable function!
@macroexpand @yield x
ERROR: LoadError: @yield macro outside a @resumable function!