Fix for luajit error handling (old Lua 5.1 API uses getfenv)
This commit is contained in:
parent
ddb839bfd4
commit
c2397620a9
@ -96,10 +96,16 @@ enhance_error = function(error_message)
|
|||||||
local action_name = fn_name:from_lua_id()
|
local action_name = fn_name:from_lua_id()
|
||||||
error_message = "The action '" .. tostring(action_name) .. "' is not defined."
|
error_message = "The action '" .. tostring(action_name) .. "' is not defined."
|
||||||
local func = debug.getinfo(2, 'f').func
|
local func = debug.getinfo(2, 'f').func
|
||||||
local ename, env = debug.getupvalue(func, 1)
|
local env
|
||||||
if not (ename == "_ENV" or ename == "_G") then
|
if _VERSION == "Lua 5.1" then
|
||||||
func = debug.getinfo(3, 'f').func
|
env = getfenv(func)
|
||||||
|
else
|
||||||
|
local ename
|
||||||
ename, env = debug.getupvalue(func, 1)
|
ename, env = debug.getupvalue(func, 1)
|
||||||
|
if not (ename == "_ENV" or ename == "_G") then
|
||||||
|
func = debug.getinfo(3, 'f').func
|
||||||
|
ename, env = debug.getupvalue(func, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local THRESHOLD = math.min(4.5, .9 * #action_name)
|
local THRESHOLD = math.min(4.5, .9 * #action_name)
|
||||||
local candidates = { }
|
local candidates = { }
|
||||||
|
@ -74,10 +74,14 @@ enhance_error = (error_message)->
|
|||||||
|
|
||||||
-- This check is necessary for handling both top-level code and code inside a fn
|
-- This check is necessary for handling both top-level code and code inside a fn
|
||||||
func = debug.getinfo(2,'f').func
|
func = debug.getinfo(2,'f').func
|
||||||
ename,env = debug.getupvalue(func, 1)
|
local env
|
||||||
unless ename == "_ENV" or ename == "_G"
|
if _VERSION == "Lua 5.1"
|
||||||
func = debug.getinfo(3,'f').func
|
env = getfenv(func)
|
||||||
|
else
|
||||||
ename,env = debug.getupvalue(func, 1)
|
ename,env = debug.getupvalue(func, 1)
|
||||||
|
unless ename == "_ENV" or ename == "_G"
|
||||||
|
func = debug.getinfo(3,'f').func
|
||||||
|
ename,env = debug.getupvalue(func, 1)
|
||||||
|
|
||||||
THRESHOLD = math.min(4.5, .9*#action_name) -- Ignore matches with strdist > THRESHOLD
|
THRESHOLD = math.min(4.5, .9*#action_name) -- Ignore matches with strdist > THRESHOLD
|
||||||
candidates = {}
|
candidates = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user