LuaLS / LuaLS/lua-language-server
Cast on global results in unknown type conversion
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, Diagnostics/Syntax Checking
### Expected Behaviour
Using `---@cast` on a global variable behaves the same as for a local variable.
### Actual Behaviour

### Reproduction steps
```
---@type integer
TestingValue = 1
---@cast TestingValue +number
```
### Additional Notes
_No response_
### Log File
[Projects_Lua.zip](https://github.com/sumneko/lua-language-server/files/9739798/Projects_Lua.zip)
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 diagnostic in the Lua snippet using the Visual Studio Code extension, then trace how the `---@cast` annotation handles the global `TestingValue` compared with a local variable. Done means casting the global no longer reports an unknown type conversion and behaves like the local-variable case.
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