From fe040633a1d64af4c19acc4707adb47413a3cd4a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 31 Jul 2019 11:22:39 -0300 Subject: Tracebacks recognize metamethods '__close' --- testes/locals.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'testes') diff --git a/testes/locals.lua b/testes/locals.lua index 6eb1ba0e..99fa79cd 100644 --- a/testes/locals.lua +++ b/testes/locals.lua @@ -316,14 +316,27 @@ do -- errors in __close assert(log[1] == 5 and log[2] == 4 and log[3] == 4 and log[4] == 4 and #log == 4) + -- error leaving a block + local function foo (...) + do + local x1 = func2close(function () error("Y") end) + local x123 = func2close(function () error("X") end) + end + end + + local st, msg = xpcall(foo, debug.traceback) + assert(string.match(msg, "^[^ ]* X")) + assert(string.find(msg, "in metamethod 'close'")) + -- error in toclose in vararg function - function foo (...) - local x123 = 10 + local function foo (...) + local x123 = func2close(function () error("X") end) end - local st, msg = pcall(foo) - assert(string.find(msg, "'x123'")) + local st, msg = xpcall(foo, debug.traceback) + assert(string.match(msg, "^[^ ]* X")) + assert(string.find(msg, "in metamethod 'close'")) end -- cgit v1.2.3-55-g6feb