Skip to content

fix(debug.getinfo): use GMod's (f, what) base signature so value-passing resolves - #19

Merged
Pollux12 merged 1 commit into
Pollux12:mainfrom
AmyJeanes:fix/debug-getinfo-base-signature
Aug 26, 2026
Merged

fix(debug.getinfo): use GMod's (f, what) base signature so value-passing resolves#19
Pollux12 merged 1 commit into
Pollux12:mainfrom
AmyJeanes:fix/debug-getinfo-base-signature

Conversation

@AmyJeanes

@AmyJeanes AmyJeanes commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Problem

custom/debug.getinfo.lua declares the base signature as the stock-Lua (thread, f, what) form. The base signature is what the analyzer uses when debug.getinfo is referenced as a first-class value (rather than called directly) — so passing it to pcall produces spurious diagnostics:

local ok, info = pcall(debug.getinfo, fn, "S")

resolves against fun(thread, f, what), giving:

  • expected 'thread' but found 'function' (fnthread)
  • expected '(function|integer)' but found '"S"' ("S"f)

GMod's documented signature is debug.getinfo(funcOrStackLevel, fields); the coroutine-first form is valid Lua 5.1 but not the common/documented shape.

Fix

Make the 2-arg (f, what) form the base signature and keep the thread-first forms as ---@overloads (adding a thread, integer overload so the coverage the old base provided is preserved).

Direct calls are unchanged — the function and level-0 non-nil refinements still apply, and an arbitrary integer stack level still resolves to debuglib.DebugInfo?. Only the value-passing case is corrected.

Verified against a real workspace: pcall(debug.getinfo, fn, "S") now resolves with no cast and no diagnostics.

🤖 Generated with Claude Code

Greptile Summary

The PR corrects debug.getinfo’s base annotation to use GMod’s two-argument (f, what) signature while retaining thread-first forms as overloads.

  • Changes the base declaration from three parameters to two.
  • Preserves function, stack-level-zero, arbitrary-integer, and thread-first typing and nullability.

Confidence Score: 5/5

The PR appears safe to merge with no actionable regressions identified.

The new base parameters retain explicit types and nullable return behavior, while the overload set continues to cover refined function, level-zero, and thread-first calls.

Important Files Changed

Filename Overview
custom/debug.getinfo.lua Correctly promotes the typed (f, what) form to the base signature and preserves thread-first integer coverage through an overload.

Reviews (1): Last reviewed commit: "fix(debug.getinfo): use GMod's (f, what)..." | Re-trigger Greptile

…ing resolves

The base signature was the stock-Lua (thread, f, what) form. Since the base
is what the analyzer uses when debug.getinfo is passed as a first-class value
(e.g. pcall(debug.getinfo, fn, "S")), that produced spurious
param-type-mismatch warnings - fn checked against `thread`, the fields string
against `f`.

GMod's documented signature is debug.getinfo(funcOrStackLevel, fields), with
the optional coroutine form still valid Lua 5.1. Make the 2-arg (f, what) form
the base and keep the thread-first forms as overloads (adding thread+integer
to preserve coverage the old base provided). Direct calls are unchanged - the
function / level-0 non-nil refinements still apply - only value-passing is fixed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018CzM9mxWHmgA5b5d926jBH
@Pollux12
Pollux12 merged commit ca3193b into Pollux12:main Aug 26, 2026
2 checks passed
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.

2 participants