You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SortedPairs, SortedPairsByValue, SortedPairsByMemberValue and RandomPairs scrape to ---@return function, so no types reach their generic-for loop variables. pairs and ipairs already carry the full generic tuple via custom/; this extends the same treatment to the other four.
Only types change — descriptions, @realm and @source are copied verbatim from the current generated output. SortedPairs keeps its single return (it returns a self-contained closure); the other three keep the state return, since they return keyValuePairs, state.
Why it matters
Without a type the loop variable is back-inferred from whatever it gets passed to, so a genuine error inside the loop isn't just missed — it becomes the evidence. The pairs control reports this; the other four accept it:
---@paramvVectorlocalfunctiontakesVector(v) returnvend---@typetable<string, string>localt= { a="x", b="y" }
forkinpairs(t) dotakesVector(k) end-- reportedforkinSortedPairs(t) dotakesVector(k) end-- accepted, k back-inferred as Vector
Verification
Whole-repo glua_check 1.1.1 over a 50k-line addon, all three passes on gluals-annotations-prerelease @ 2c8a727e:
annotations
suppressions
result
current
in place
clean
current
removed
7 × infer-unknown, all sorted-pairs loop variables
this PR
removed
clean
Retires 7 suppressions with no new diagnostics.
The state-return descriptions match the wiki as it now reads — I corrected those pages first (SortedPairs documented a second return it doesn't have, RandomPairs omitted the one it does, and both SortedPairsBy* described the state record as the source table), so this PR is purely the missing types.
Test added alongside the existing iterator one. Note cli-change-checker.spec.ts and one other suite already fail to compile on main — unrelated to this change.
Disclosure: this was researched and written by Claude Code working in my repositories. Every claim was reproduced and verified against real workspaces rather than asserted, and we went through it together before I raised it. Happy to adjust the shape of the annotations if you'd prefer them written differently.
Retargeted this from main to beta — I'd originally opened it against the default branch without checking which branch feeds which channel. Since gluals-annotations-prerelease is generated from beta, the change needed to land there to reach the prerelease annotations.
The branch is now based on beta rather than main, so the diff is just the five files. The four overrides are unchanged (custom/Global.ipairs.lua is byte-identical on both branches, so the convention they follow is the same either way); the test was rewritten to match beta's custom-annotations.spec.ts, which uses the readCustom helper and toContain.
One caveat on verification: most tests in that file read from output/, which isn't committed and needs a full scrape to produce, so I could only run the new test in isolation (npx jest custom-annotations -t 'sorted-pairs' — passes, the other 16 skip). npx tsc --noEmit -p tsconfig.test.json is clean. Happy to drop the test or reshape it if you'd rather it asserted against the generated output/global.lua like the neighbouring ones.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SortedPairs,SortedPairsByValue,SortedPairsByMemberValueandRandomPairsscrape to---@return function, so no types reach their generic-for loop variables.pairsandipairsalready carry the full generic tuple viacustom/; this extends the same treatment to the other four.Only types change — descriptions,
@realmand@sourceare copied verbatim from the current generated output.SortedPairskeeps its single return (it returns a self-contained closure); the other three keep the state return, since they returnkeyValuePairs, state.Why it matters
Without a type the loop variable is back-inferred from whatever it gets passed to, so a genuine error inside the loop isn't just missed — it becomes the evidence. The
pairscontrol reports this; the other four accept it:Verification
Whole-repo
glua_check1.1.1 over a 50k-line addon, all three passes ongluals-annotations-prerelease@2c8a727e:infer-unknown, all sorted-pairs loop variablesRetires 7 suppressions with no new diagnostics.
The state-return descriptions match the wiki as it now reads — I corrected those pages first (
SortedPairsdocumented a second return it doesn't have,RandomPairsomitted the one it does, and bothSortedPairsBy*described the state record as the source table), so this PR is purely the missing types.Test added alongside the existing iterator one. Note
cli-change-checker.spec.tsand one other suite already fail to compile onmain— unrelated to this change.Disclosure: this was researched and written by Claude Code working in my repositories. Every claim was reproduced and verified against real workspaces rather than asserted, and we went through it together before I raised it. Happy to adjust the shape of the annotations if you'd prefer them written differently.