diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2022-05-30 21:45:25 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2022-05-30 21:45:25 +0100 |
commit | a100ebb3d79c1de0e57e0a5e1d00c6c64f3af710 (patch) | |
tree | 815999a69d25c3a0849b7405be3f7f2eaba893f0 | |
parent | a05a58b2588377bcb214f0ef28c1342b3b67dc17 (diff) | |
download | mlua-a100ebb3d79c1de0e57e0a5e1d00c6c64f3af710.zip |
Fix luaL_requiref glb handling for Lua<=5.1
-rw-r--r-- | src/ffi/lua51/compat.rs | 5 | ||||
-rw-r--r-- | src/ffi/luau/compat.rs | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/ffi/lua51/compat.rs b/src/ffi/lua51/compat.rs index 9cd46fb..c67dbe0 100644 --- a/src/ffi/lua51/compat.rs +++ b/src/ffi/lua51/compat.rs @@ -568,11 +568,10 @@ pub unsafe fn luaL_requiref( lua_getfield(L, -1, modname); } } - if cfg!(feature = "lua51") && glb != 0 { + if glb != 0 { lua_pushvalue(L, -1); lua_setglobal(L, modname); - } - if cfg!(feature = "luajit") && glb == 0 { + } else { lua_pushnil(L); lua_setglobal(L, modname); } diff --git a/src/ffi/luau/compat.rs b/src/ffi/luau/compat.rs index eae4612..117d1d5 100644 --- a/src/ffi/luau/compat.rs +++ b/src/ffi/luau/compat.rs @@ -513,6 +513,9 @@ pub unsafe fn luaL_requiref( if glb != 0 { lua_pushvalue(L, -1); lua_setglobal(L, modname); + } else { + lua_pushnil(L); + lua_setglobal(L, modname); } lua_replace(L, -2); } |