summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-03-22 17:57:59 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-03-22 17:57:59 +0800
commit91ae26be49374dee87d09f0fe9160cb393e4fef7 (patch)
tree6ac7d2ee8b984a6f23829a24ff8870460d0e1172
parentb8627365c0abe5a9d40c91f81b2aef7ea869faad (diff)
downloadlua-language-server-91ae26be49374dee87d09f0fe9160cb393e4fef7.zip
recover mark before return
fix #2004
-rw-r--r--changelog.md2
-rw-r--r--script/vm/type.lua1
-rw-r--r--test/diagnostics/type-check.lua17
3 files changed, 20 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 59a3ca68..4f5b7b73 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,10 +3,12 @@
## 3.6.18
* `FIX` [#1943]
* `FIX` [#1996]
+* `FIX` [#2004]
* `FIX` [#2013]
[#1943]: https://github.com/LuaLS/lua-language-server/issues/1943
[#1996]: https://github.com/LuaLS/lua-language-server/issues/1996
+[#2004]: https://github.com/LuaLS/lua-language-server/issues/2004
[#2013]: https://github.com/LuaLS/lua-language-server/issues/2013
## 3.6.17
diff --git a/script/vm/type.lua b/script/vm/type.lua
index 756926ba..8382eb86 100644
--- a/script/vm/type.lua
+++ b/script/vm/type.lua
@@ -466,6 +466,7 @@ function vm.isSubType(uri, child, parent, mark, errs)
if ext.type == 'doc.extends.name'
and (not isBasicType or guide.isBasicType(ext[1]))
and vm.isSubType(uri, ext[1], parent, mark, errs) == true then
+ mark[childName] = nil
return true
end
end
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index 4abe5855..18e7190d 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -1238,6 +1238,23 @@ local arr2 = {
}
]]
+TEST [[
+---@class A
+
+---@class B : A
+
+---@class C : B
+
+---@class D : B
+
+---@param x A
+local function func(x) end
+
+---@type C|D
+local var
+func(var)
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')