lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Nil check for functions

Open OscarCreator opened this issue 1 year ago • 0 comments

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

  1. Run example

Additional Notes

No response

Log File

No response

OscarCreator avatar Feb 15 '24 18:02 OscarCreator