diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-11-08 20:51:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-11-08 20:51:16 +0800 |
commit | e7f8bc78843c03c677668a676f124902b2b889a2 (patch) | |
tree | ab5fbb692c12713eab2abee9a9464d49b6a77601 | |
parent | 49de63caf1b60807b031bb90d8c8fc7dfd65622a (diff) | |
download | lua-language-server-e7f8bc78843c03c677668a676f124902b2b889a2.zip |
fix #1676
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | script/core/diagnostics/param-type-mismatch.lua | 14 | ||||
-rw-r--r-- | test/diagnostics/type-check.lua | 10 |
3 files changed, 23 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md index 02ef0f4a..19e8d5c9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # changelog +## 3.6.2 +* `FIX` [#1676] +[#1676]: https://github.com/sumneko/lua-language-server/issues/1676 + ## 3.6.1 `2022-11-8` * `FIX` wrong diagnostics for `pcall` and `xpcall` diff --git a/script/core/diagnostics/param-type-mismatch.lua b/script/core/diagnostics/param-type-mismatch.lua index 1fe5fa94..c67eac50 100644 --- a/script/core/diagnostics/param-type-mismatch.lua +++ b/script/core/diagnostics/param-type-mismatch.lua @@ -9,10 +9,7 @@ local function expandGenerics(defNode) local generics = {} for dn in defNode:eachObject() do if dn.type == 'doc.generic.name' then - local limits = dn.generic.extends - if limits then - generics[#generics+1] = dn - end + generics[#generics+1] = dn end end @@ -22,7 +19,14 @@ local function expandGenerics(defNode) for _, generic in ipairs(generics) do local limits = generic.generic.extends - defNode:merge(vm.compileNode(limits)) + if limits then + defNode:merge(vm.compileNode(limits)) + else + local unknownType = vm.getGlobal('type', 'unknown') + if unknownType then + defNode:merge(unknownType) + end + end end end diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index 5243ecec..434cf5bc 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -1078,6 +1078,16 @@ local y local x = y ]] +TEST [[ +---@generic T +---@param v1 T +---@param v2 T|table +local function func(v1, v2) +end + +func('hello', 'world') +]] + config.remove(nil, 'Lua.diagnostics.disable', 'unused-local') config.remove(nil, 'Lua.diagnostics.disable', 'unused-function') config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global') |