Skip to content

Commit 5ccedb1

Browse files
committed
check doc.field
#1990
1 parent 01a741f commit 5ccedb1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

script/core/diagnostics/inject-field.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ return function (uri, callback)
5050
if def.type == 'doc.type.field' then
5151
return
5252
end
53+
if def.type == 'doc.field' then
54+
return
55+
end
5356
end
5457

5558
local howToFix = lang.script('DIAG_INJECT_FIELD_FIX_CLASS', {

test/diagnostics/inject-field.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,26 @@ local m
3939
m.xx = 1 -- OK
4040
m.yy = 1 -- OK
4141
]]
42+
43+
TEST [[
44+
---@class Class
45+
---@field x number
46+
47+
---@type Class
48+
local t
49+
50+
t.x = 1 -- OK
51+
t.<!y!> = 2 -- Warning
52+
]]
53+
54+
TEST [[
55+
---@class Class
56+
---@field x number
57+
---@field [any] any
58+
59+
---@type Class
60+
local t
61+
62+
t.x = 1 -- OK
63+
t.y = 2 -- OK
64+
]]

0 commit comments

Comments
 (0)