LuaLS / LuaLS/lua-language-server

[Feature Request] Allow mark any as @enum

Open
#2,820 2 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

### Issue Description

```lua
---@enum Type
local Type = {
A = 1,
B = 2,
-- ...
}

---@return {[string]: integer}
function Generate_enum()
return {}
end

---@enum (partial) Type
local Type2 = {}

for k, v in pairs(Generate_enum()) do
Type2[k] = v
end

---@enum (partial) Type
local Type3 = Generate_enum()

```

![image](https://github.com/user-attachments/assets/10ea02f0-eed9-41c9-9d62-9f107623496e)

![image](https://github.com/user-attachments/assets/e9a9dce5-ccb3-4d15-b031-645d15913a72)

The point is to achieve the same behavior for `Type3` as for `Type2`.

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 by reproducing the issue's Lua examples and inspect the language server's existing @enum handling and type inference for assignments. Compare Type2 and Type3, then add coverage so a partial enum assigned directly from Generate_enum() receives the same behavior as the incremental assignment; done means their diagnostics and type information match.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.