diff options
Diffstat (limited to 'testes')
-rw-r--r-- | testes/coroutine.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 680fc605..17f6ceba 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -505,6 +505,25 @@ assert(not pcall(a, a)) | |||
505 | a = nil | 505 | a = nil |
506 | 506 | ||
507 | 507 | ||
508 | do | ||
509 | -- bug in 5.4: thread can use message handler higher in the stack | ||
510 | -- than the variable being closed | ||
511 | local c = coroutine.create(function() | ||
512 | local clo <close> = setmetatable({}, {__close=function() | ||
513 | local x = 134 -- will overwrite message handler | ||
514 | error(x) | ||
515 | end}) | ||
516 | -- yields coroutine but leaves a new message handler for it, | ||
517 | -- that would be used when closing the coroutine (except that it | ||
518 | -- will be overwritten) | ||
519 | xpcall(coroutine.yield, function() return "XXX" end) | ||
520 | end) | ||
521 | |||
522 | assert(coroutine.resume(c)) -- start coroutine | ||
523 | local st, msg = coroutine.close(c) | ||
524 | assert(not st and msg == 134) | ||
525 | end | ||
526 | |||
508 | -- access to locals of erroneous coroutines | 527 | -- access to locals of erroneous coroutines |
509 | local x = coroutine.create (function () | 528 | local x = coroutine.create (function () |
510 | local a = 10 | 529 | local a = 10 |