LuaLS / LuaLS/lua-language-server
How to make a third-party member function as deprecated
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?
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.

2. and works unexpectedly.

### 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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