print'-'
pcall(function()
local t=coroutine.running()
delay(1,function()
coroutine.resume(t)
end)
print'yielding'
coroutine.yield()
print'resumed'
end)
print'a'--never outputted, but should be
Replacing pcall with ypcall doesn’t work either
But the code runs with no problems if coroutines are replaced with wait() or BindableEvents
I think this problem is similar to a lot of other ones with coroutines also
local pcall=function(f,...)
local t=coroutine.running()
local ret
local wk=setmetatable({},{__mode='v'})
coroutine.wrap(function(...)
local ret2=table.pack(pcall(function(...)
local w=newproxy()
wk[1]=w
ret=table.pack(true,f(...))
coroutine.resume(t)
end,...))
if not ret then
ret=ret2
coroutine.resume(t)
end
end)(...)
_G'gc'(wk[1],function()
if not ret then
ret={false,'unknown bc pcall bug'}
coroutine.resume(t)
end
end)
if not ret then coroutine.yield()end
return unpack(ret,1,ret.n)
end
but it unfortunately has the side effect that stack traces and the error messages are unknown when the function does coroutine yield, and the gc method which is __GC (Mind blowing) means unnecessary yielding if the function coroutine yields