Being able to block at scope exit (in Lua, from a "__close" metamethod hand control back to the coroutine scheduler via "yield") is fundamental to implementing structured concurrency.
Would there be any way to lift this restriction from the to-be-closed implementation?
coro = coroutine.create(function()
local foo <close> = setmetatable({}, {
__close = function(a) coroutine.yield('bar') end
})
end)
assert(coroutine.resume(coro))
--> "attempt to yield across a C-call boundary"