Skip to content

Fix Tool class override regression - #15

Merged
Pollux12 merged 1 commit into
betafrom
fix/tool-regression
Jul 27, 2026
Merged

Fix Tool class override regression#15
Pollux12 merged 1 commit into
betafrom
fix/tool-regression

Conversation

@Pollux12

Copy link
Copy Markdown
Owner

Summary

  • preserve the exact identity of planned direct page overrides across class alias groups
  • emit a distinct canonical class.* override alongside a direct alias-page override
  • reserve planned page overrides before output-file traversal to prevent order-dependent duplicate emission
  • add multi-file regression coverage matching the real Tool / TOOL layout

Root 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. Tool and TOOL resolve to the same canonical class, but custom/class.Tool.lua and custom/TOOL.lua are separate overrides with different responsibilities. The direct TOOL override therefore caused the canonical Tool override to be dropped.

An initial identity-based correction also exposed an output-order problem: when structures.lua was processed before the planned tool.lua owner, the direct TOOL override 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.lua once again contains the Tool declaration and supporting types, so standard stool code can resolve methods such as self:GetOwner(), self:GetClientNumber(), and self:GetStage(). Direct structure overrides remain de-duplicated.

Validation

  • npm test -- --runInBand __tests__/api-writer/glua-api-writer.spec.ts — 63 tests passed
  • npm test -- --runInBand __tests__/custom-class-override.spec.ts __tests__/cli-generate-lua.spec.ts — 12 tests passed
  • npm run typecheck
  • real-data regeneration confirmed exactly one each of Tool, ToolObjectSlot, ToolObjects, Tool:GetOwner, TOOL.AddToMenu, HullTrace, SoundData, Trace, and EntityCopyData
  • independent review exercised all five alias pairs in both registration orders and found no remaining actionable issues

Closes #14

@Pollux12
Pollux12 marked this pull request as ready for review July 27, 2026 19:24
@Pollux12
Pollux12 merged commit 36333e2 into beta Jul 27, 2026
1 check passed
@Pollux12
Pollux12 deleted the fix/tool-regression branch July 27, 2026 19:52
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant