LuaLS / LuaLS/lua-language-server

How to make a third-party member function as deprecated

Open
#2,784 11 comments 0 reactions 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

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

Diagnostics/Syntax Checking

### Expected Behaviour

```lua
---@deprecated
M.add = M.add
```
The left one should have marked as deprecated immediately when used such as ~u:add~

### Actual Behaviour

1. it not works first.
![QQ_1722841266627](https://github.com/user-attachments/assets/6d27266b-1c94-4210-9b11-b42051fefe3b)
2. and works unexpectedly.
![QQ_1722841307997](https://github.com/user-attachments/assets/e082f762-4d47-472b-9337-a4fdea7c2a94)

### Reproduction steps

1. Write the code
```lua
-- File A

---@class A
local A = {}

---@param attr string
function A.add(attr)
end

-- File B

---@class A
local B = A

---@deprecated
B.add = A.add

B.add('some attr')
```
We'll find that B.add havn't marked as deprecated
2. Keep write the followed
```lua
-- File C

---@class A
---@field add fun(attr: string)
local C = A
```

### Additional Notes

My original intention was to mark a third-party member function as deprecated.
As there was no straightforward way, I think, to do it, I had to use a lot of tricks, which led to more subsequent problems.

### 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 with the File A, File B, and File C reproduction in the issue, focusing on how the diagnostic marks B.add after the deprecated assignment. Run the reproduction in the Visual Studio Code extension and compare the observed diagnostics with the expected deprecation warning for B.add.

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.