summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-09 00:49:07 +0800
committerruki <[email protected]>2026-01-09 00:49:07 +0800
commitf14ff9651eb38e519749eb9727d15c0a6199adac (patch)
tree48639437d0e7de919ab4ec2c6ce77fbf258c5158
parent5ec8f01cf2e953e1a9536aba194e4cfd43d123f3 (diff)
fix getfenv
-rw-r--r--xmake/core/base/compat/env.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/xmake/core/base/compat/env.lua b/xmake/core/base/compat/env.lua
index 722c5f97c..ec21c271b 100644
--- a/xmake/core/base/compat/env.lua
+++ b/xmake/core/base/compat/env.lua
@@ -55,7 +55,7 @@ else -- >= Lua 5.2
end
f = debug.getinfo(f + 2, 'f').func
elseif type(f) ~= 'function' then
- error(("bad argument #1 to '%s' (number expected, got %s)"):format(type(name, f)), 2)
+ error(("bad argument #1 to '%s' (number expected, got %s)"):format(name, type(f)), 2)
end
return f
end
@@ -79,8 +79,9 @@ else -- >= Lua 5.2
-- 5.1 style `getfenv` implemented in 5.2
function env.getfenv(f)
- if f == 0 or f == nil then return _G end -- simulated behavior
- local f = envhelper(f, 'setfenv')
+ if f == 0 then return _G end -- simulated behavior
+ f = f or 1
+ local f = envhelper(f, 'getfenv')
local up, val = envlookup(f)
if not up then return _G end -- simulated behavior [**]
return val