LuaLS / LuaLS/lua-language-server
Feature request: Infer overload annotations for subsequent overloads
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
It would be useful for subsequent function overload definitions to use prior annotations unless a new annotation is provided.
Such as:
---An example function
---@param a integer
---@param b string
---@param c function Some documentation about c
---@return boolean
---@overload fun(c)
---@overload fun(a): nil
function foo(a, b, c) end
being equivalent to
---An example function
---@param a integer
---@param b string
---@param c function Some documentation about c
---@return boolean
function foo(a, b, c) end
---An example function
---@param c function Some documentation about c
---@return boolean
function foo(c)
---An example function
---@param a integer
---@return nil
function foo(a)
With auto-generated documentation this isn't so much of a problem, but it's a bit of a chore when it's something to be done by hand.
Appreciate all the work you've done! This makes writing Lua so much more confident.
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
No files or tests are named in the issue. Start by locating the handling of @overload and parameter/return annotations, then add focused coverage for inheriting prior annotations and overriding them when an overload supplies new ones. Done means the two overloads in the example receive the documented inherited and explicit annotations without changing the original definition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100