LuaLS / LuaLS/lua-language-server

Adding an overload to an @class changes the result and gives type errors.

Open
#2,978 5 comments 3 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

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

Adding an Overload under ---@class should not change anything about how the type is handled.

Actual Behaviour

image

Here we have a class declaration and it's exactly how I want.

image

Adding an overload for the constructor generates warnings? Doesn't really make any sense.

Reproduction steps

Use ---@class to define a class.
Add ---@overload.
Make sure the class library you're using returns anything but any when extending or creating a new class.

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

The payload names no source file or test; start by reproducing the case in the Visual Studio Code extension with a Lua ---@class declaration and ---@overload, then compare type-checking results with and without the overload. Trace the class and constructor handling involved, and consider the issue resolved when adding the overload no longer changes valid type handling or produces the reported warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, vscode
Domain
devtools
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.