From cd6169cf3ecaa41a0aec1cfddd98284fa831285c Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 10 Mar 2025 16:12:53 +0100 Subject: Fix unit tests failing for Lua 5.3 * Fix compatibility function lua_getiuservalue() for Lua 5.3 * Fix handling of nil function upvalues in lanes.nameof() --- src/compat.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/compat.cpp') diff --git a/src/compat.cpp b/src/compat.cpp index c332ddc..7e90142 100644 --- a/src/compat.cpp +++ b/src/compat.cpp @@ -120,9 +120,9 @@ int lua_getiuservalue(lua_State* const L_, StackIndex const idx_, UserValueIndex #endif// LUA_VERSION_NUM > 501 STACK_CHECK(L_, 1); int const _uvType{ lua_type(L_, -1) }; - // under Lua 5.2, there is a single uservalue that is either nil or a table. - // If nil, don't transfer it, as it can cause issues when copying to a Keeper state because of nil sentinel conversion - return (LUA_VERSION_NUM == 502 && _uvType == LUA_TNIL) ? LUA_TNONE : _uvType; + // under Lua 5.2 and 5.3, there is a single uservalue, that can be nil. + // emulate 5.4 behavior by returning LUA_TNONE when that's the case + return (_uvType == LUA_TNIL) ? LUA_TNONE : _uvType; } // ################################################################################################# -- cgit v1.2.3-55-g6feb