summaryrefslogtreecommitdiff
path: root/test/diagnostics/init.lua
diff options
context:
space:
mode:
authoruhziel <uhziel@gmail.com>2020-12-09 17:20:58 +0800
committeruhziel <uhziel@gmail.com>2020-12-09 17:20:58 +0800
commitcdb0368c12640c3fb6faa00eabeff7572f677061 (patch)
treeb983607b0576014bf627993e292fba687d88c7ee /test/diagnostics/init.lua
parent65b56557d79637135ce59ff6ceda44c35d8518e4 (diff)
downloadlua-language-server-cdb0368c12640c3fb6faa00eabeff7572f677061.zip
添加检测"未定义的 field"
Diffstat (limited to 'test/diagnostics/init.lua')
-rw-r--r--test/diagnostics/init.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index c05a29ae..0e932ede 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -823,3 +823,23 @@ TEST [[
---@class class
local t
]]
+
+TEST [[
+---@class Foo
+---@field field1 integer
+local mt = {}
+function mt:Constructor()
+ self.field2 = 1
+end
+function mt:method1() return 1 end
+function mt.method2() return 2 end
+
+---@type Foo
+local v
+print(v.field1 + 1)
+print(v.field2 + 1)
+print(<!v.field3!> + 1)
+print(v:method1())
+print(v.method2())
+print(<!v:method3!>())
+]]