summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md4
-rw-r--r--script/vm/compiler.lua12
-rw-r--r--test/diagnostics/type-check.lua11
3 files changed, 27 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 46aa7ae1..b502fde8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,9 @@
# changelog
+## 3.6.8
+* `FIX` [#1831]
+[#1831]: https://github.com/sumneko/lua-language-server/issues/1831
+
## 3.6.7
`2023-1-20`
* `FIX` [#1810]
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index a3057629..a438d06f 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1325,6 +1325,18 @@ local compilerSwitch = util.switch()
end
end
+ if not hasMarkDoc and source.type == 'tableindex' then
+ vm.compileByParentNode(source.node, vm.ANY, function (src)
+ if src.type == 'doc.field'
+ or src.type == 'doc.type.field' then
+ if vm.isSubType(guide.getUri(source), vm.compileNode(source.index), vm.compileNode(src.field or src.name)) then
+ hasMarkDoc = true
+ vm.setNode(source, vm.compileNode(src))
+ end
+ end
+ end)
+ end
+
if not hasMarkDoc and source.value then
vm.setNode(source, vm.compileNode(source.value))
end
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index 908920b9..ba0c78b4 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -1117,6 +1117,17 @@ local B = "World"
local x = A
]]
+TEST [[
+local enum = { a = 1, b = 2 }
+
+---@type { [integer] : boolean }
+local t = {
+ <![enum.a]!> = 1,
+ <![enum.b]!> = 2,
+ <![3]!> = 3,
+}
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')