Skip to content

How to make a third-party member function as deprecated #2784

Open
@ChouUn

Description

@ChouUn

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

---@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
  2. and works unexpectedly.
    QQ_1722841307997

Reproduction steps

  1. Write the code
-- 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions