LuaLS / LuaLS/lua-language-server
Unexpected typechecking (with classes only?)
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?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
MacOS
What is the issue affecting?
Type Checking
Expected Behaviour
---@param a string
---@return string
local function expandHeader(a) return a end
---@class baz
---@field header string?
---@type baz
local foo = {}
local bar = foo.header
expandHeader(foo.header) -- param-type-mismatch
expandHeader(bar) -- param-type-mismatch
Actual Behaviour
---@param a string
---@return string
local function expandHeader(a) return a end
---@class baz
---@field header string?
---@type baz
local foo = {}
local bar = foo.header
expandHeader(foo.header) -- NO WARNING
expandHeader(bar) -- param-type-mismatch
Reproduction steps
See actual behavior
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 with the Lua reproduction in the issue and inspect the type-checking path for nullable fields on annotated classes. Confirm the behavior for both expandHeader(foo.header) and expandHeader(bar); done means both calls report the expected parameter-type mismatch.
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
- 45/100