LuaLS / LuaLS/lua-language-server
Multiple return values for fields
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?
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
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 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