Fix scope stack staying broken after a yield in strict mode (#105)
Some checks failed
unit-test / unit-test (push) Has been cancelled

* Fix scope stack staying broken after a yield in strict mode

* Warn on a yield in strict mode instead of cancelling the thread

* Fix type error when an effect errors outside strict mode
This commit is contained in:
Kaan 2026-10-22 15:56:38 +03:00 • committed by GitHub
parent d99dbe1873
commit 033d30fbfb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 12 deletions

View file

@ -3146,7 +3146,7 @@ end))
TEST("strict", wrap_root(function()
vide.strict = true
do CASE "error on derived callback yield"
do CASE "warn on derived callback yield"
local src = source(1)
local ok = pcall(function()
@ -3156,10 +3156,10 @@ TEST("strict", wrap_root(function()
end)
end)
CHECK(not ok)
CHECK(ok)
end
do CASE "error on effecter callback yield"
do CASE "warn on effecter callback yield"
local src = source(1)
local ok = pcall(function()
@ -3169,7 +3169,28 @@ TEST("strict", wrap_root(function()
end)
end)
CHECK(not ok)
CHECK(ok)
end
do CASE "yield in a component"
local input = source(false)
local thread
local output
local destroy = root(function()
output = show(input, function()
thread = coroutine.running()
coroutine.yield()
return "component"
end)
end)
CHECK((pcall(input, true)))
CHECK(output() == nil)
CHECK((coroutine.resume(thread)))
CHECK(output() == "component")
CHECK(pcall(input, false))
CHECK(pcall(destroy))
end
do CASE "run derived callback twice"