LuaLS / LuaLS/lua-language-server

---@return self

Open
#2,002 3 comments 0 reactions 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

### 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?

Type Checking

### Expected Behaviour

![image](https://user-images.githubusercontent.com/57856647/224538065-e8913564-0b63-4325-af4d-77f422aac25a.png)

### Actual Behaviour

![image](https://user-images.githubusercontent.com/57856647/224538053-e9e57090-832f-454e-b457-bfbd6a53c920.png)

### Reproduction steps

```lua
---@class Test1
local Test1 = {};

---@return self
function Test1:New()
return setmetatable({}, { __indeex = self });
end

---@class Test2 : Test1
local Test2 = {};

local test1 = Test1:New();
local test2 = Test2:New();
```

### 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 by running the Lua reproduction in the issue through the language server's type checking in the Visual Studio Code extension on Windows, then compare the inferred types for Test1:New() and Test2:New(). Done means the return annotation is handled consistently for the base and derived classes, with the reported type-checking mismatch resolved.

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.