a8ea6429e1
release / release (push) Successful in 3s
WoW 3.3.5 Lua 5.1 runtime has table.setn as an error stub ("'setn' is obsolete")
and table.getn missing/erroring. The embedded Ace2 libs (AceLibrary, AceOO, AceEvent,
AceConsole, AceDebug, AceDB, Tablet-2.0) all assign table_setn = table.setn at module
scope when GetBuildInfo() does not start with "2." — causing AceOO-2.0 to crash at
line 546 before any library can register, then cascading to AceConsole/FuBarPlugin.
Add Lua50Compat.lua as the first TOC entry to unconditionally overwrite table.setn
(no-op) and table.getn (returns #t) before any lib loads. Also shims
table.foreach/foreachi in case future libs need them. Verified with LuaJIT 5.1:
AceLibrary + AceOO load cleanly; all other libs stop only at WoW-API boundaries
(not at obsolete-call errors).
43 lines
1.4 KiB
Lua
43 lines
1.4 KiB
Lua
-- Lua50Compat.lua
|
|
-- Loaded FIRST (see VanillaGuide.toc) to restore Lua 5.0 table functions that
|
|
-- the WoW 3.3.5 / Project Ascension Lua 5.1 runtime has made obsolete.
|
|
--
|
|
-- table.setn existed in 5.0 to manually hint the array length; in 5.1 the
|
|
-- length operator (#) is authoritative and table.setn is a stub that raises
|
|
-- "attempt to call a nil value" or "'setn' is obsolete". Overwrite it with a
|
|
-- no-op unconditionally so Ace2 libs (AceOO, AceEvent, AceConsole, AceDebug,
|
|
-- AceLibrary, AceDB, Tablet-2.0) can assign the local alias at module load
|
|
-- time without erroring.
|
|
--
|
|
-- table.getn existed in 5.0 as the canonical length function; in 5.1 it was
|
|
-- removed (or kept as an error stub on some runtimes). Replace it with the
|
|
-- equivalent # operator.
|
|
--
|
|
-- table.foreach / table.foreachi were removed in 5.1 as well; guard them in
|
|
-- case any lib uses them (none currently do, but safe to shim anyway).
|
|
|
|
-- Unconditional overwrite -- even if these slots exist they may raise.
|
|
table.setn = function() end
|
|
|
|
table.getn = function(t)
|
|
return #t
|
|
end
|
|
|
|
if not table.foreach then
|
|
table.foreach = function(t, f)
|
|
for k, v in pairs(t) do
|
|
local ret = f(k, v)
|
|
if ret then return ret end
|
|
end
|
|
end
|
|
end
|
|
|
|
if not table.foreachi then
|
|
table.foreachi = function(t, f)
|
|
for i = 1, #t do
|
|
local ret = f(i, t[i])
|
|
if ret then return ret end
|
|
end
|
|
end
|
|
end
|