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

Unexpected typechecking (with classes only?)

Open Rathoz opened this issue 4 months ago • 2 comments

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

Rathoz avatar Sep 03 '25 13:09 Rathoz

I don't understand the as designed label added by @CppCXY here because it looks like a legitimate issue. I also expect a warning for both cases. Does it mean that it's a consequence of the current design and can't be easily fixed?

firas-assaad avatar Oct 01 '25 20:10 firas-assaad

My mistake, I mixed up expected and actual.

CppCXY avatar Oct 02 '25 01:10 CppCXY