feat(lua): cap upvalues at Lua 5.1's 60 rather than the byte

The limit shipped at 255, the structural ceiling -- f->nups and
LClosure.nupvalues are lu_byte, so that is the most a closure can hold.
But the point of the change is that a function valid on a 5.1 client
should load here, and 5.1's own MAXUPVALUES is 60. Anything past that is
not a compatibility gap, it is an invitation to write something no other
client would accept, which is not a thing to be first at.

One constant. Nothing in either hook depends on which number it is: the
spill path, the stale-clear and the emission loop are unchanged, and the
refusal still comes from the engine's own luaY_checklimit, so its message
carries whichever limit is in force.

Verified in-game: 60 upvalues load and sum correctly, 61 fails with
"too many upvalues (limit=60)".
This commit is contained in:
Brues
2026-09-06 14:16:39 -05:00
parent e68b690cf1
commit 991baa2610
4 changed files with 21 additions and 14 deletions
+6 -6
View File
@@ -9285,15 +9285,15 @@ needs that addon's opt-in.
### Upvalue limit
A function can use up to 255 upvalues — the outer locals it refers to.
A function can use up to 60 upvalues — the outer locals it refers to.
Lua 5.0 stops at 32 and rejects the whole file with `too many upvalues
(limit=32)`. Lua 5.1 allows 60. A large handler that reads many file-level
locals can be valid Lua 5.1 and still fail to load here for that reason
alone. ClassicAPI raises the limit to 255, the most a closure can hold.
(limit=32)`. A large handler that reads many file-level locals can be
valid Lua 5.1, which allows 60, and still fail to load here for that
reason alone. ClassicAPI raises the limit to the same 60.
Nothing changes for a function within the old limit. Past 255 the error is
the same message with the new number: `too many upvalues (limit=255)`.
Nothing changes for a function within the old limit. Past 60 the error is
the same message with the new number: `too many upvalues (limit=60)`.
### String methods (`s:upper()`, `s:format(...)`)