Skip to content

refactor(semantic): specialize operator function storage - #1063

Merged
CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
lewis6991:refactor/operator-function-storage
May 12, 2026
Merged

CppCXY merged 1 commit into
EmmyLuaLs:mainfrom
lewis6991:refactor/operator-function-storage

Conversation

@lewis6991

@lewis6991 lewis6991 commented May 7, 2026

Copy link
Copy Markdown
Collaborator
  • store annotation operators with operator-specific shapes instead of always using LuaFunctionType
  • keep @overload, runtime metatable signatures, and default constructors on function-shaped paths
  • fold typed field/index operators into the binary operator representation

@lewis6991
lewis6991 force-pushed the refactor/operator-function-storage branch from 83b97ae to 13b2748 Compare May 7, 2026 11:50

@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 refactors the representation of Lua operators by introducing a specialized OperatorFunction enum with variants for binary, unary, call, and overload operations. This change improves the precision of operator analysis but introduces a regression in get_operator_func, where the reconstructed function signatures for binary and unary operators omit the required self parameter. Additionally, the implementation for the Overload variant incorrectly strips the first parameter, which will result in inaccurate signature help for developers.

Comment thread crates/emmylua_code_analysis/src/db_index/operators/lua_operator.rs
@lewis6991
lewis6991 force-pushed the refactor/operator-function-storage branch 2 times, most recently from 80af06c to f8084e8 Compare May 7, 2026 12:02
@lewis6991

Copy link
Copy Markdown
Collaborator Author

/gemini review

@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 refactors the OperatorFunction enum into specific variants—BinOp, UnOp, Call, and Overload—to more accurately represent Lua operators and simplify their analysis. The review feedback identifies that the Call variant lacks an is_vararg field, which leads to the loss of variadic information and incorrect function reconstruction. Furthermore, a debug_assert! added to get_operand for non-binary operators is flagged as potentially too restrictive compared to the previous implementation.

Comment thread crates/emmylua_code_analysis/src/db_index/operators/lua_operator.rs Outdated
Comment thread crates/emmylua_code_analysis/src/db_index/operators/lua_operator.rs
Comment thread crates/emmylua_code_analysis/src/db_index/operators/lua_operator.rs Outdated
@lewis6991
lewis6991 force-pushed the refactor/operator-function-storage branch 2 times, most recently from 4cdbff0 to 6da0795 Compare May 7, 2026 12:16
@lewis6991

Copy link
Copy Markdown
Collaborator Author

/gemini review

Store annotation operators as operator-specific shapes instead of using
LuaFunctionType for every operator. Keep overloads, runtime signatures,
and default constructors on the function-shaped paths where those fields
still matter.

Assisted-by: Codex

@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 refactors the representation of Lua operators by replacing the generic OperatorFunction::Func variant with more specific variants: BinOp, UnOp, Call, and Overload. This change simplifies the analysis of metamethods and improves type inference for various operator types, including support for variadic call operators. A new test case was added to ensure that variadic call operators do not trigger incorrect redundant parameter diagnostics. I have no feedback to provide.

@lewis6991
lewis6991 force-pushed the refactor/operator-function-storage branch from 6da0795 to cf4aa99 Compare May 7, 2026 12:22
@CppCXY
CppCXY merged commit 75ca68b into EmmyLuaLs:main May 12, 2026
16 checks passed
@lewis6991
lewis6991 deleted the refactor/operator-function-storage branch May 12, 2026 14:02
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