Skip to content

feat(diagnostic): add non-callable call checker - #940

Merged
CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
lewis6991:split-call-non-function
Feb 3, 2026
Merged

CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
lewis6991:split-call-non-function

Conversation

@lewis6991

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @lewis6991, 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 introduces a new diagnostic checker that identifies and flags attempts to invoke expressions that are not callable. It enhances the type analysis capabilities by providing precise warnings when non-function types like numbers, strings, or booleans are treated as functions. The changes include the implementation of the checker, its integration into the diagnostic system, and a refinement in type inference caching to ensure accurate reporting.

Highlights

  • New Diagnostic Checker: Introduced CallNonCallableChecker to identify and report attempts to call expressions that are not functions or callable types.
  • Improved Type Inference: The checker leverages the semantic model to infer the type of the expression being called, including handling union types to pinpoint specific non-callable components.
  • Detailed Error Messages: Diagnostic messages now provide specific information about the non-callable type(s) involved, aiding in debugging.
  • Diagnostic System Integration: The new checker is integrated into the existing diagnostic pipeline, ensuring it runs during code analysis.
  • Cache Management Enhancement: Modified the infer_call_expr_func to prevent "sticky" cache entries for InferFailReason::None, improving inference accuracy.
  • Comprehensive Testing: Added a dedicated test file (call_non_callable_test.rs) with various scenarios to validate the checker's behavior, including cases with union types and initializer fallbacks.

🧠 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.

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 introduces a new diagnostic checker to detect calls to non-callable expressions. The overall implementation is good, but I've found a critical logic error in how union types are handled, which will cause false-positive diagnostics. There's also a section of logic that is unclear and could lead to incorrect behavior, which I've suggested refactoring for clarity and correctness. Additionally, some of the new tests are written to expect the buggy behavior and will need to be updated along with the implementation fix. The other changes, such as wiring up the new checker and improving the call inference cache, look solid.

@lewis6991
lewis6991 force-pushed the split-call-non-function branch 4 times, most recently from b933710 to 8be56e5 Compare January 31, 2026 21:07
@lewis6991
lewis6991 force-pushed the split-call-non-function branch from 8be56e5 to 9da9d4d Compare February 2, 2026 09:30
insert_if_non_callable(t);
}
}
LuaType::TypeGuard(inner) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typeguad is actually treated as a boolean

&InferGuard::new(),
None,
);
if let Err(reason) = &call_result {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should use ".ok()?" directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

How? I need access to reason.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, it just feels like the logic here is redundant — why are there two if statements?

@lewis6991
lewis6991 force-pushed the split-call-non-function branch from 9da9d4d to 7eafe3d Compare February 3, 2026 11:25
@CppCXY
CppCXY merged commit a19c7db into EmmyLuaLs:main Feb 3, 2026
21 of 22 checks passed
@lewis6991
lewis6991 deleted the split-call-non-function branch February 3, 2026 15:37
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