LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.36k stars 320 forks source link

inconsistent behavior for `diagnosis (missing-fields)`. #2769

Closed NeOzay closed 3 months ago

NeOzay commented 3 months ago

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

a warning is triggered when declaring a table with missing fields

Actual Behaviour

the diagnosis is not triggered if the annotation is declared several times.

I don't know if it would be useful if the diagnosis could also search for the defined fields of the class?

Reproduction steps

---@class Foo
---@field x number
---@field y number

---@class Foo
Foo = {}
Foo.x = 1
Foo.y = 2

---@type Foo 
local foo = {} -- not trigger

Additional Notes

I will open a PR for this problem.

Log File

No response