[Tarantool-patches] [PATCH v2 luajit 21/30] test: disable test for getfenv in closure tailcall

Sergey Kaplun skaplun at tarantool.org
Fri Mar 26 10:43:04 MSK 2021


LuaJIT doesn't take into account tail calls for call-level counting, so
getfenv() behaviour is different from Lua 5.1 in tail calls.

This patch disables test for the return result of tail call getfenv().
Default value (equals 1) of getfenv() function's argument (function
level) is invalid for this tail call -- LuaJIT can't provide necessary
debug information for the frame.

Relates to tarantool/tarantool#5713
Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
---
 test/PUC-Lua-5.1-tests/closure.lua | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/test/PUC-Lua-5.1-tests/closure.lua b/test/PUC-Lua-5.1-tests/closure.lua
index 7f56ab8..7af842f 100644
--- a/test/PUC-Lua-5.1-tests/closure.lua
+++ b/test/PUC-Lua-5.1-tests/closure.lua
@@ -174,7 +174,14 @@ f = coroutine.wrap(foo)
 local a = {}
 assert(f(a) == _G)
 local a,b = pcall(f)
-assert(a and b == _G)
+-- LuaJIT doesn't take into account tail calls for call-level
+-- counting, so getfenv() behaviour is different in tail calls.
+-- For example, this `pcall()` returns false, because getfenv()
+-- default level is 1 which is invalid for this case when
+-- is called from tail call (lj_debug_frame() returns NULL).
+-- See also https://github.com/tarantool/tarantool/issues/5713.
+-- FIXME: Test is disabled for LuaJIT for now.
+-- assert(a and b == _G)
 
 
 -- tests for multiple yield/resume arguments
-- 
2.31.0



More information about the Tarantool-patches mailing list