LuaLS / LuaLS/lua-language-server
literal strings 'async' is mis-parsed
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?
Linux
### What is the issue affecting?
Annotations
### Expected Behaviour
The following should work without errors:
```lua
---@class Unit
---@field mode "async" | "sync"
```
and:
```lua
---@type Unit
local test = {}
test.mode = (hint) --> "async" or "sync"
```
### Actual Behaviour
The follow shows an error
```lua
---@class Unit
---@field mode "async" (error here: expected.) | "sync"
```
and:
```lua
---@type Unit
local test = {}
test.mode = (hint) --> "sync"
```
### Reproduction steps
1. Copy and paste the expected behavior codeblock.
### Additional Notes
Only happens with `async` as far as I can see.
### 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 examples in the Visual Studio Code extension and compare how the parser handles the literal string "async" with "sync". Trace the annotation/type-name handling that produces the expected error, then add coverage showing both literal values are accepted without changing the reported type hint.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100