Fix Tool class override regression - #15
Merged
Merged
Conversation
Pollux12
marked this pull request as ready for review
July 27, 2026 19:24
AmyJeanes
added a commit
to AmyJeanes/gmod-addon-tools
that referenced
this pull request
Jul 27, 2026
Picks up the fix for annotations-gmod-glua-ls#14, where the TOOL struct override claimed the canonical `Tool` name and dropped `custom/class.Tool.lua` whole, so every method reached through `self` in a stool file was unresolvable. Pollux12/annotations-gmod-glua-ls#15 restores `---@Class Tool` and additionally declares `---@Class TOOL : Tool`, binding the struct to the class explicitly. That unblocks Safe-Space, held at v0.29.8 because the four undefined-method errors it got on the standard stool pattern would have failed its CI. Verified clean against all six consumers at this digest. The rest of the diff is upstream wiki prose (particle-system and GetViewEntity notes); no other type surface moves. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01981VsF54AGHofDBHZrpawA
AmyJeanes
added a commit
to AmyJeanes/Safe-Space
that referenced
this pull request
Jul 27, 2026
Held at v0.29.8 because v0.29.9's annotations dropped `---@Class Tool`, which made every method reached through `self` in a stool file unresolvable - four undefined-method errors on the standard Sandbox tool pattern, enough to fail CI. Pollux12/annotations-gmod-glua-ls#15 restores the class and additionally declares `---@Class TOOL : Tool`; v0.29.10 pins that digest. Bumped by hand rather than waiting on Renovate, since Safe-Space is the only consumer the regression affected and its v0.29.9 PR could never go green. Both gates verified clean locally beforehand. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01981VsF54AGHofDBHZrpawA
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
class.*override alongside a direct alias-page overrideTool/TOOLlayoutRoot cause
The structure de-duplication added for #8 used the canonical class name as a proxy for whether a page override had already been emitted.
ToolandTOOLresolve to the same canonical class, butcustom/class.Tool.luaandcustom/TOOL.luaare separate overrides with different responsibilities. The directTOOLoverride therefore caused the canonicalTooloverride to be dropped.An initial identity-based correction also exposed an output-order problem: when
structures.luawas processed before the plannedtool.luaowner, the directTOOLoverride could be emitted twice. The final implementation precomputes the exact planned override addresses before any output files are written, making emission independent of file order.Impact
Generated
tool.luaonce again contains theTooldeclaration and supporting types, so standard stool code can resolve methods such asself:GetOwner(),self:GetClientNumber(), andself:GetStage(). Direct structure overrides remain de-duplicated.Validation
npm test -- --runInBand __tests__/api-writer/glua-api-writer.spec.ts— 63 tests passednpm test -- --runInBand __tests__/custom-class-override.spec.ts __tests__/cli-generate-lua.spec.ts— 12 tests passednpm run typecheckTool,ToolObjectSlot,ToolObjects,Tool:GetOwner,TOOL.AddToMenu,HullTrace,SoundData,Trace, andEntityCopyDataCloses #14