LuaLS / LuaLS/lua-language-server

Unexpected typechecking (with classes only?)

Open
#3,262 2 comments 0 reactions 0 assignees View on GitHub
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

```lua
---@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

```lua
---@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

Open the contributing guide

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.