LuaLS / LuaLS/lua-language-server

Diagnostics.(param-type-mismatch)

Open
#1,414 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement feat/type check
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

---@enum Test
local Test = {
    Test1 = 1,
    Test2 = 2,
    Test3 = 2,
}

---@type Test|Test[]
local a

---@param c Test
local function b(c) end

if type(a) == "table" then
    b(a[1]);
else
    b(a);
end

---@class Class
---@field a Test|Test[]
local Class = {};

function Class:Test()
    if type(self.a) == "table" then
        b(self.a[1]);
    else
        b(self.a);
    end
end

image
image

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

No source file or test is named. Start by reproducing the shown Lua snippet and inspecting the param-type-mismatch diagnostics for both the local union and the class field; done means the diagnostics correctly handle the type narrowed by each type check.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.