From 91ae26be49374dee87d09f0fe9160cb393e4fef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 22 Mar 2023 17:57:59 +0800 Subject: recover mark before return fix #2004 --- changelog.md | 2 ++ script/vm/type.lua | 1 + test/diagnostics/type-check.lua | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) 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') -- cgit v1.2.3