Skip to content

Hide implicit self from __call signature help - #1613

Open
Companion wants to merge 1 commit into
JohnnyMorganz:mainfrom
Companion:fix/signature-help-call-metamethod-self
Open

Hide implicit self from __call signature help#1613
Companion wants to merge 1 commit into
JohnnyMorganz:mainfrom
Companion:fix/signature-help-call-metamethod-self

Conversation

@Companion

Copy link
Copy Markdown

Problem

Signature help for a table invoked through its __call metamethod includes the first metamethod parameter:

local module = setmetatable({}, {
    __call = function(self, value: string)
    end,
})

module()

Luau supplies self implicitly, so callers cannot provide it. However, signature help currently displays:

function module(self: any, value: string): ()

and reports both values as caller provided parameters.

Change

Build __call signature help from a copy of the metamethod type with its implicit first argument removed. The corrected signature is:

function module(value: string): ()

This removes self from both the displayed label and the LSP parameter list while preserving parameter offsets, active parameter tracking and documentation indices for the remaining arguments.

Ordinary function calls and existing method call (:) behaviour are unchanged. The separate method call label behaviour tracked by #1250 remains outside the scope of this change.

Fixes #1597.

Testing

Added focused signature help tests covering:

  • Removing the implicit argument from the label and parameter list
  • __call metamethods containing only self
  • Multiple explicit parameters and their label offsets
  • Active parameter tracking
  • Variadic parameters
  • Parameter documentation indices
  • Mixed named and unnamed arguments
  • Unchanged ordinary function behaviour

The new tests were verified to be load bearing by temporarily disabling the trimming and documentation offset behaviour.

…hods

The table being called is bound to the metamethod's first parameter, so the
caller never supplies it. Drop it from the label and the reported parameters,
while keeping the original index when looking up parameter documentation.

Fixes JohnnyMorganz#1597
@Companion
Companion force-pushed the fix/signature-help-call-metamethod-self branch from 6ee573f to af8243a Compare August 31, 2026 20:57
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.

__call showing self parameter when calling table

1 participant