LuaLS / LuaLS/lua-language-server
assign-type-mismatch not reported for global values
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?
Annotations, Type Checking, Diagnostics/Syntax Checking
### Expected Behaviour
With a global table that has type-annotated fields, reassigning a field to an incorrectly-typed value should report `[assign-type-mismatch]`
### Actual Behaviour
No diagnostic is reported, even though autocompletion indicates that the type is understood by the server. Further, assigning a local variable to the global value and doing the same thing _does_ report the diagnostic correctly.
### Reproduction steps
```lua
---@class test
_G.test = {
---@type boolean
foo = true,
}
test.foo = 'bar' -- no error
_G.test.foo = 'bar' -- no error
local test2 = test
test2.foo = 'bar' -- [assign-type-mismatch]
```
### 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 running the supplied Lua reproduction and compare diagnostics for test.foo, _G.test.foo, and test2.foo. Trace the type-checking and diagnostics path for global values; done means the two global assignments report [assign-type-mismatch] consistently with the local alias case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100