mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
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:
+6
-6
@@ -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(...)`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user