LuaLS / LuaLS/lua-language-server

Multiple return values for fields

Open
#2,357 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat/LuaCats Annotations
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?

Annotations

### Expected Behaviour

The ability to define multiple return values for a field annotation.

### Actual Behaviour

Any non-identifier symbol following a type is treated as a comment or a break.

### Reproduction steps

1. Create a field with a comma separated return type.
2. See that anything following the comma is treated as a comment.

### Additional Notes

```lua
---@class Color
---@field [string] Color,string
Color = {}
```
`,string` is highlighted as a comment.
```lua
---@class Color
---@field [string] Color, string
Color = {}
```
`,` is highlighted as a symbol, ` string` is highlighted as a comment.

---
An example of fields with multiple return types are the named color lookups in the Tabletop Simulator API:
https://api.tabletopsimulator.com/color/#colorblue

```lua
local color, name = Color.Blue
print(color) -- Color: Blue { r = 0.118, g = 0.53, b = 1, a = 1 }
print(name) -- Blue

local color, name = Color.Red
print(color) -- Color: Red { r = 0.856, g = 0.1, b = 0.094, a = 1 }
print(name) -- Red
```

### 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 by reproducing the annotation parser behavior with the provided Lua snippets, focusing on how comma-separated types after an @field declaration are tokenized. Done means multiple return types such as Color,string are recognized as annotation types rather than treating the remainder as a comment; add or update coverage if the repository has relevant parser tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.