Skip to content

fix(code-analysis): strip implicit self from doc call operators - #980

Merged
CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
lewis6991:fix/selfcallarg
Mar 13, 2026
Merged

CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
lewis6991:fix/selfcallarg

Conversation

@lewis6991

Copy link
Copy Markdown
Collaborator

Normalize doc-defined ---@operator call functions by dropping the
implicit self parameter when exposing them as callable function types.
This fixes false missing-parameter and param-type-mismatch
diagnostics for zero-arg call operators and chained method calls on
their return values.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses incorrect diagnostic reporting for ---@operator call functions defined in documentation. By normalizing the function signatures of these operators to correctly account for implicit self parameters, it eliminates false missing-parameter and param-type-mismatch errors, improving the accuracy of code analysis.

Highlights

  • Doc-defined Call Operators: Implemented logic to strip the implicit self parameter from ---@operator call functions when converting them to callable function types.
  • Diagnostic Fixes: Resolved false missing-parameter and param-type-mismatch diagnostics that occurred with zero-argument call operators and chained method calls on their return values.
  • New Functionality: Introduced to_call_operator_func_type in LuaFunctionType to handle the normalization of call operator function signatures.
  • Test Coverage: Added new test cases to missing_parameter_test.rs and param_type_check_test.rs to validate the fix for call operator diagnostics.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • crates/emmylua_code_analysis/src/db_index/operators/lua_operator.rs
    • Modified get_operator_func to apply special handling for Call meta-methods, using to_call_operator_func_type to normalize their function signatures.
  • crates/emmylua_code_analysis/src/db_index/type/types.rs
    • Added a new method to_call_operator_func_type to LuaFunctionType which creates a new function type with the implicit self parameter removed if present.
  • crates/emmylua_code_analysis/src/diagnostic/test/missing_parameter_test.rs
    • Added a new test test_call_operator_implicit_self to verify that missing-parameter diagnostics are correctly suppressed for call operators with implicit self.
  • crates/emmylua_code_analysis/src/diagnostic/test/param_type_check_test.rs
    • Added a new test test_call_operator_implicit_self_param_type to ensure param-type-mismatch diagnostics are correctly handled for call operators.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses incorrect diagnostics for ---@operator call by normalizing function types and introducing to_call_operator_func_type to handle call operators, with new tests confirming fixes for missing-parameter and param-type-mismatch errors. No security vulnerabilities were found, and the implementation appears correct with no further suggestions for improvement.

@lewis6991
lewis6991 marked this pull request as draft March 9, 2026 15:10
Strip only the synthetic receiver from doc-defined `---@operator call`
signatures when exposing them as callable function types.

Preserve user-authored overload parameters named or typed `self`, and
keep generic instantiation working for explicit-self call overloads like
`fun<T>(self: self, value: T): T`.

This fixes false `missing-parameter` and `param-type-mismatch`
diagnostics for doc call operators while preserving `self`-returning
overloads and constructor-style call inference.

Add regressions for chained call-operator methods, parameter type
checks, explicit `self` overloads, and generic explicit-self call
overloads.
@lewis6991
lewis6991 marked this pull request as ready for review March 9, 2026 16:13
@CppCXY
CppCXY merged commit 15168ec into EmmyLuaLs:main Mar 13, 2026
22 checks passed
@lewis6991
lewis6991 deleted the fix/selfcallarg branch March 13, 2026 11:29
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