LuaLS / LuaLS/lua-language-server

enum inherits fields from class with different name

Open
#2,304 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations

Expected Behaviour

As far as enum has unique name, this warning should not exist.

Actual Behaviour

Here is my annotations:

-- RenderMode.Regular, path: ['viewscreen_titlest', 'menu_line_id'], container
---@class viewscreen_titlest.menu_line_id_C
---@field [integer] viewscreen_titlest.menu_line_id
---@field resize fun(self: self, size: integer): nil
---@field insert fun(self: self, index: "#"|integer, item: viewscreen_titlest.menu_line_id): nil
---@field erase fun(self: self, index: integer): nil
---@field assign fun(self: self, obj: self): nil
---@field delete fun(self: self): boolean
---@field _displace fun(self: self, index: integer): self
---@field _kind "primitive"|"struct"|"container"|"bitfield"
---@field _type table | string
df.viewscreen_titlest.menu_line_id_C = nil

-- RenderMode.Regular, path: ['viewscreen_titlest', 'menu_line_id'], enum
---@enum viewscreen_titlest.menu_line_id
df.viewscreen_titlest.menu_line_id = {
    Continue = 0,
    Start = 1,
    NewWorld = 2,
    TestingArena = 3, -- nonfunctional in 50.04
    Mods = 4, -- nonfunctional in 50.04 since v50.01
    Settings = 5,
    AboutDF = 6,
    Quit = 7,
}

As you can see, there are different typenames and objects names.
But enum requires class fields.

Missing required fields in type `viewscreen_titlest.menu_line_id_C`: `resize`, `insert`, `erase`, `assign`, `delete`, `_displace`, `_kind`, `_type`
image
Reproduction steps

Get code above and check.

Additional Notes

No response

Log File

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the annotated reproduction in the issue and trace how the language server resolves the @enum and @class declarations when their type and object names differ. Verify the diagnostic that reports the class fields as missing, then confirm that the warning is absent for this distinct enum while genuine required-field checks remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.