LuaLS / LuaLS/lua-language-server
Nil check for functions
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, Diagnostics/Syntax Checking
Expected Behaviour
---@class Type1
---@field maybe_fun? fun(a: integer)
---@field absolutely_nil nil
---@type Type1
local type {
maybe_fun = nil
absolutely_nil = nil
}
type.maybe_fun(5) -- ERROR "maybe_fun" is nil, add nil check
type.absolutely_nil() -- ERROR "absolutely_nil" is nil
Actual Behaviour
---@class Type1
---@field maybe_fun? fun(a: integer)
---@field absolutely_nil nil
---@type Type1
local type {
maybe_fun = nil
absolutely_nil = nil
}
-- No error messages, luals does not complain at all
type.maybe_fun(5)
type.absolutely_nil()
Reproduction steps
- Run example
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
The issue names no source file or test; start by reproducing the Lua example in NeoVim on Linux and trace the type-checking and diagnostic entry point for calls through nil-typed fields. Done means diagnostics report both nil call cases shown, including the optional function and the field typed as nil.
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
- 45/100