diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-08-14 15:16:43 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-08-14 15:16:43 +0800 |
commit | 5ccedb1cf07a73a8e0eb4ace84b320c8a997dbbb (patch) | |
tree | 24aa7115913a56d8bba3575c1a92835ca4ca3108 | |
parent | 01a741f8416f074199303235eb533b8f3446e85b (diff) | |
download | lua-language-server-5ccedb1cf07a73a8e0eb4ace84b320c8a997dbbb.zip |
check `doc.field`
#1990
-rw-r--r-- | script/core/diagnostics/inject-field.lua | 3 | ||||
-rw-r--r-- | test/diagnostics/inject-field.lua | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/script/core/diagnostics/inject-field.lua b/script/core/diagnostics/inject-field.lua index 139b8636..570ca270 100644 --- a/script/core/diagnostics/inject-field.lua +++ b/script/core/diagnostics/inject-field.lua @@ -50,6 +50,9 @@ return function (uri, callback) if def.type == 'doc.type.field' then return end + if def.type == 'doc.field' then + return + end end local howToFix = lang.script('DIAG_INJECT_FIELD_FIX_CLASS', { diff --git a/test/diagnostics/inject-field.lua b/test/diagnostics/inject-field.lua index 2c802270..f4d847e9 100644 --- a/test/diagnostics/inject-field.lua +++ b/test/diagnostics/inject-field.lua @@ -39,3 +39,26 @@ local m m.xx = 1 -- OK m.yy = 1 -- OK ]] + +TEST [[ +---@class Class +---@field x number + +---@type Class +local t + +t.x = 1 -- OK +t.<!y!> = 2 -- Warning +]] + +TEST [[ +---@class Class +---@field x number +---@field [any] any + +---@type Class +local t + +t.x = 1 -- OK +t.y = 2 -- OK +]] |