LuaLS / LuaLS/lua-language-server
Using a union of string literals as a table key doesn't force use of the keys
Open
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?
NeoVim
Which OS are you using?
Linux
What is the issue affecting?
Type Checking
Expected Behaviour
---@alias SomeUnion
--- | 'a'
--- | 'b'
---@type table<SomeUnion, number>
local a
should work roughly like
---@class (exact) SomeUnion
---@field a number
---@field b number
local a
Actual Behaviour
Reproduction steps
---@alias SomeUnion
--- | 'a'
--- | 'b'
---@type table<SomeUnion, number>
local a = {
c = "should be invalid"
}
Additional Notes
No response
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 reported type-checking example in the issue and trace the language server's handling of table keys whose type is a string-literal union. Done means the c key in the reproduction is reported invalid while the a and b keys remain valid.
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
- Clearly specified
- Newbie friendliness
- 45/100