LuaLS / LuaLS/lua-language-server

Feature request: Infer overload annotations for subsequent overloads

Open
#2,309 0 comments 0 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

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.