This part of section 3.4.7 (The Length Operator) is very vague on what
should happen when 'border' is the maximum integer:
"
The length operator applied on a table returns a border in that table.
A border in a table t is any natural number that satisfies the
following condition:
(border == 0 or t[border] ~= nil) and t[border + 1] == nil
The implementation (Lua 5.4.4 rc2 on a 64-bit Apple M1) will happily return 'maxinteger' for a small table, like this sample shows:
local T, k = {}, 1
repeat
T[k], k = true, k << 1
until k <= 0
T[math.maxinteger] = true
print(#T) -- prints 4
T[#T+1] = true
print(#T) -- prints maxinteger