LuaLS / LuaLS/lua-language-server

Multipe parameters infer differently?

Open
#1,343 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Infers a and aa correctly but not the rest

---@diagnostic disable: codestyle-check, spell-check, unused-local

---@alias AnyChild A|B|C
---@class PARENT
local PARENT = {}
---@class A: PARENT
local A = {}
---@class B: PARENT
local B = {}
---@class C: PARENT
local C = {}

---@overload fun(self:PARENT): A
---@overload fun(self:AnyChild, other: A): A
---@overload fun(self:AnyChild, other: B): B
function PARENT:new(other)
  self.a = 2
  return {}
end

local a = A:new()
local aa = a:new()

local aaa = a:new(B)
local b = B:new(B)
local bb = b:new(B)
local bbb = b:new(C)

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

Start with the embedded Lua reproduction and inspect the language server's inferred types for aaa, b, bb, and bbb compared with a and aa. Trace overload resolution for colon calls and multiple parameters, then add or run a focused regression test that confirms the expected inferred types for all examples.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.