From e657a48ea5698bbd9982d878eb65e6615ec94f7e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 13 Jun 2025 14:08:38 -0300 Subject: The main thread cannot be closed No thread started with pcall (instead of resume) can be closed, because coroutine.close would not respect the expected number of results from the protected call. --- testes/coroutine.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'testes') diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 02536ee5..4881d964 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua @@ -158,6 +158,11 @@ do local main = coroutine.running() + -- cannot close 'main' + local st, msg = pcall(coroutine.close, main); + assert(not st and string.find(msg, "main")) + + -- cannot close a "normal" coroutine ;(coroutine.wrap(function () local st, msg = pcall(coroutine.close, main) -- cgit v1.2.3-55-g6feb