diff --git a/changelog.md b/changelog.md index 46aa7ae15..b502fde84 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 a30576292..a438d06fc 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 908920b96..ba0c78b48 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 = { + = 1, + = 2, + = 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')