summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeOzay <colpaert.benoit@gmail.com>2024-07-13 17:21:17 +0200
committerNeOzay <colpaert.benoit@gmail.com>2024-07-13 17:21:17 +0200
commitb77daee2d5788c34b48d8ea0c13d754c2d943a3a (patch)
tree52ffb60552e7d5b16d7c262fb6d3ad34fe7750f3
parent9fa74cb832f4d0af6bc1cd2ef6ec537c64d4025c (diff)
parent256689690a107b134b642c6d7b1b57cc77c95f69 (diff)
downloadlua-language-server-b77daee2d5788c34b48d8ea0c13d754c2d943a3a.zip
Merge branch 'fix-missing-check-for-'inject-field'' into fixes-a-specific-case-for-getVisibleType
-rw-r--r--changelog.md1
-rw-r--r--script/core/diagnostics/inject-field.lua3
-rw-r--r--test/diagnostics/inject-field.lua13
3 files changed, 17 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 9b76e27a..5ecbf46b 100644
--- a/changelog.md
+++ b/changelog.md
@@ -8,6 +8,7 @@
* `FIX` Respect `completion.showParams` config for local function completion
* `CHG` Improve performance of multithreaded `--check` and `undefined-field` diagnostic
* `FIX` Now correctly evaluates the visibility of fields in a class when they are defined directly in the object. use for completion and invisible dianostic. [#2752](https://github.com/LuaLS/lua-language-server/issues/2752)
+* `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)
## 3.9.3
`2024-6-11`
diff --git a/script/core/diagnostics/inject-field.lua b/script/core/diagnostics/inject-field.lua
index 2866eef8..e1ef02a3 100644
--- a/script/core/diagnostics/inject-field.lua
+++ b/script/core/diagnostics/inject-field.lua
@@ -68,6 +68,9 @@ return function (uri, callback)
if def.type == 'doc.field' then
return
end
+ if def.type == 'tablefield' and not isExact then
+ return
+ end
end
local howToFix = ''
diff --git a/test/diagnostics/inject-field.lua b/test/diagnostics/inject-field.lua
index 9bb0f8fc..d5b49701 100644
--- a/test/diagnostics/inject-field.lua
+++ b/test/diagnostics/inject-field.lua
@@ -82,3 +82,16 @@ function m:init() -- OK
end
end
]]
+
+TEST [[
+---@class Class
+local m = {
+ xx = 1, -- OK
+}
+
+---@type Class
+local m
+
+m.xx = 1 -- OK
+m.<!yy!> = 1 -- Warning
+]]