summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-08-11 18:39:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-08-11 18:39:51 +0800
commited350080cfb3998fa95abb905cfa363f546e70ce (patch)
tree1c3f90dde731371cc0481b064a997472b1fc5243
parentce2b607822d142afdcd0bd5ca7156b43ea011a56 (diff)
downloadlua-language-server-ed350080cfb3998fa95abb905cfa363f546e70ce.zip
fix stack overflow
-rw-r--r--script/vm/type.lua6
-rw-r--r--test/hover/init.lua13
2 files changed, 19 insertions, 0 deletions
diff --git a/script/vm/type.lua b/script/vm/type.lua
index dd7b359f..910d7960 100644
--- a/script/vm/type.lua
+++ b/script/vm/type.lua
@@ -143,6 +143,9 @@ end
---@param errs? typecheck.err[]
---@return boolean?
local function checkChildEnum(childName, parent , uri, mark, errs)
+ if mark[childName] then
+ return
+ end
local childClass = vm.getGlobal('type', childName)
if not childClass then
return nil
@@ -157,11 +160,14 @@ local function checkChildEnum(childName, parent , uri, mark, errs)
if not enums then
return nil
end
+ mark[childName] = true
for _, enum in ipairs(enums) do
if not vm.isSubType(uri, vm.compileNode(enum), parent, mark ,errs) then
+ mark[childName] = nil
return false
end
end
+ mark[childName] = nil
return true
end
diff --git a/test/hover/init.lua b/test/hover/init.lua
index 7d91c385..63220a59 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -2475,3 +2475,16 @@ local <?x?>
[[
local x: A
]]
+
+TEST [[
+---@type A
+local <?f?>
+
+---@enum A
+local t = {
+ x = f,
+}
+]]
+[[
+local f: A
+]]