mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-17 08:24:39 +00:00
The v1.12.8 gap heuristic (keep the stored length when it overshoots the border by exactly one) protected `table.insert(t, nil)` slots (#36) but broke every 5.1-dialect table that is stale by exactly one — a pairs-cleared one-element table, or a recycled table whose previous life was one slot longer. Tablet-2.0's del()/copy() pool produces the latter on every tooltip refresh, so FuBar/Ace2/Tablet menus and tooltips shifted by one with a nil hole at slot 1. The two states are byte-identical, and both consumers reach the heal through table.insert — neither the table nor the caller can split them. Only the writer knows which dialect the table speaks, and the write is observable: co-hook the engine's table.insert (FUN_LUA_TABLE_INSERT = 0x7FB6B0, verified against the table-lib luaL_reg pair in .data and a decompile matching 5.0.2 tinsert line for line) and record {table -> stored length} in a weak-keyed registry table whenever the two-arg form appends a literal nil. Rule 3 now heals every stale table to the border (the 5.1 answer) and keeps the stored length only when the gap is one AND the mark still matches. Stale marks die on their own: any later insert/remove moves the stored length off the recorded value, and the weak key collects with the table. Verified in-game with a 21-test suite (directed regressions for #29/#36/#39, byte-identical twin discrimination, metamethod isolation, coroutine-side marking, and a seeded differential fuzzer against an executable model of the contract): 15/21 on the broken build, 21/21 with the fix, #36's nil-append cases among the passes both times. New plumbing: LUA_SET_METATABLE (0x6F4020, from LuaCAPI.md) and Game::Lua::SetMetatable for building the weak mark table from C. Fixes #39