Skip to content

Commit 33ba775

Browse files
authored
Merge pull request #2747 from NeOzay/master
fix: add a missing check for 'inject-field' diagnostics
2 parents b773037 + bfafcef commit 33ba775

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* `NEW` Add support for lambda style functions, `|paramList| expr` is syntactic sugar for `function(paramList) return expr end`
88
* `FIX` Respect `completion.showParams` config for local function completion
99
* `CHG` Improve performance of multithreaded `--check` and `undefined-field` diagnostic
10+
* `FIX` Bad triggering of the `inject-field` diagnostic, when the fields are declared at the creation of the object [#2746](https://github.com/LuaLS/lua-language-server/issues/2746)
1011
* `CHG` Change spacing of parameter inlay hints to match other LSPs, like `rust-analyzer`
1112

1213
## 3.9.3

script/core/diagnostics/inject-field.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ return function (uri, callback)
6868
if def.type == 'doc.field' then
6969
return
7070
end
71+
if def.type == 'tablefield' and not isExact then
72+
return
73+
end
7174
end
7275

7376
local howToFix = ''

test/diagnostics/inject-field.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,16 @@ function m:init() -- OK
8282
end
8383
end
8484
]]
85+
86+
TEST [[
87+
---@class Class
88+
local m = {
89+
xx = 1, -- OK
90+
}
91+
92+
---@type Class
93+
local m
94+
95+
m.xx = 1 -- OK
96+
m.<!yy!> = 1 -- Warning
97+
]]

0 commit comments

Comments
 (0)