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

No warning when assign constant `nil` to required table field

Open d-enk opened this issue 1 year ago • 1 comments

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

Warning when assign constant nil to required table field as it happens with ordinary variables

Actual Behaviour

image

Reproduction steps

---@type number
local n

n = nil
n = 1

---@class A
---@field n number

---@type A
local a = { n = nil }

a.n = 1

local NIL = nil
a.n = NIL

-- BUT no warning
a.n = nil -- ?

_ = { a, n }

Additional Notes

Most likely this is a duplicate but I couldn't find the issue

Log File

No response

d-enk avatar Sep 08 '23 16:09 d-enk

why? https://github.com/LuaLS/lua-language-server/commit/e5f07d0c9830afdfa1ce3b354a123212e5837526

d-enk avatar Jan 09 '24 13:01 d-enk