diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-06-13 14:08:38 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-06-13 14:08:38 -0300 |
| commit | e657a48ea5698bbd9982d878eb65e6615ec94f7e (patch) | |
| tree | 2a121476070495f31f9adb201aed7bdb2b48c75a /testes | |
| parent | fd897027f19288ce2cb0249cb8c1818e2f3f1c4c (diff) | |
| download | lua-e657a48ea5698bbd9982d878eb65e6615ec94f7e.tar.gz lua-e657a48ea5698bbd9982d878eb65e6615ec94f7e.tar.bz2 lua-e657a48ea5698bbd9982d878eb65e6615ec94f7e.zip | |
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.
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/coroutine.lua | 5 |
1 files changed, 5 insertions, 0 deletions
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 | |||
| 158 | 158 | ||
| 159 | local main = coroutine.running() | 159 | local main = coroutine.running() |
| 160 | 160 | ||
| 161 | -- cannot close 'main' | ||
| 162 | local st, msg = pcall(coroutine.close, main); | ||
| 163 | assert(not st and string.find(msg, "main")) | ||
| 164 | |||
| 165 | |||
| 161 | -- cannot close a "normal" coroutine | 166 | -- cannot close a "normal" coroutine |
| 162 | ;(coroutine.wrap(function () | 167 | ;(coroutine.wrap(function () |
| 163 | local st, msg = pcall(coroutine.close, main) | 168 | local st, msg = pcall(coroutine.close, main) |
