LuaLS / LuaLS/lua-language-server

Cannot infer value type

Open
#1,341 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Latest Vscode, Latest Master

---@generic V: string
---@param list V[]
---@return {[V]: true}
util.list_to_map = function(list)
  local map = {}
  for k, value in pairs(list) do
    map[value] = true
  end
  return map
end

image
bug.log

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

Reproduce the inference failure in VS Code using the Lua snippet from the issue and inspect the attached bug.log for diagnostics. Trace the language-server handling of the generic V parameter and the returned map type; done when the example infers the value type without the reported error.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.