Skip to content

fix: add version check for meta decl member resolution - #1012

Merged
CppCXY merged 2 commits into
EmmyLuaLs:mainfrom
EfveZombie:fix.meta-decl-version-check
Apr 7, 2026
Merged

CppCXY merged 2 commits into
EmmyLuaLs:mainfrom
EfveZombie:fix.meta-decl-version-check

Conversation

@EfveZombie

Copy link
Copy Markdown

Add a version check when resolving meta declaration members, filtering out overloads that do not match the configured Lua version.

@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 Lua version checks using check_member_version when resolving member types and owner IDs for meta declarations. The review feedback points out that these changes lack fallback logic, which could lead to inconsistent behavior compared to other resolution methods. Specifically, returning LuaType::Never or None when no version matches may break type inference and navigation features like 'Go to Definition' for members defined in other Lua versions.

Comment on lines +90 to +91
if feature.is_meta_decl()
&& check_member_version(db, LuaSemanticDeclId::Member(member.get_id()))

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.

high

When MemberTypeResolveState::Meta is active, this change causes the function to return LuaType::Never if no meta declarations match the current Lua version. This behavior is inconsistent with resolve_member_semantic_id (lines 221-235), which provides a fallback to the last meta declaration if no version match is found. Returning Never can break type inference for members that have meta definitions for other Lua versions but are missing an explicit definition for the current one. Consider implementing a similar fallback or ensuring that the state only switches to Meta if a version-compatible declaration exists.

Comment on lines +166 to +167
if feature.is_meta_decl()
&& check_member_version(db, LuaSemanticDeclId::Member(member.get_id()))

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.

high

Similar to the issue in resolve_member_type, returning None here when no meta declarations match the version can lead to missing definitions for features like "Go to Definition" or type owner resolution. To maintain consistency with resolve_member_semantic_id, consider falling back to the first available meta declaration if none match the version criteria.

@EfveZombie
EfveZombie force-pushed the fix.meta-decl-version-check branch from 496c2fc to e18a4e7 Compare April 3, 2026 20:47
@CppCXY
CppCXY merged commit f2a879d into EmmyLuaLs:main Apr 7, 2026
16 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