LuaLS / LuaLS/lua-language-server

literal strings 'async' is mis-parsed

Open
#3,402 0 comments 0 reactions 0 assignees View on GitHub
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.

Image

### Log File

_No response_

Contributor guide

Open the contributing guide

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.