Skip to content

Commit ed35008

Browse files
committed
fix stack overflow
1 parent ce2b607 commit ed35008

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

script/vm/type.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ end
143143
---@param errs? typecheck.err[]
144144
---@return boolean?
145145
local function checkChildEnum(childName, parent , uri, mark, errs)
146+
if mark[childName] then
147+
return
148+
end
146149
local childClass = vm.getGlobal('type', childName)
147150
if not childClass then
148151
return nil
@@ -157,11 +160,14 @@ local function checkChildEnum(childName, parent , uri, mark, errs)
157160
if not enums then
158161
return nil
159162
end
163+
mark[childName] = true
160164
for _, enum in ipairs(enums) do
161165
if not vm.isSubType(uri, vm.compileNode(enum), parent, mark ,errs) then
166+
mark[childName] = nil
162167
return false
163168
end
164169
end
170+
mark[childName] = nil
165171
return true
166172
end
167173

test/hover/init.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,3 +2475,16 @@ local <?x?>
24752475
[[
24762476
local x: A
24772477
]]
2478+
2479+
TEST [[
2480+
---@type A
2481+
local <?f?>
2482+
2483+
---@enum A
2484+
local t = {
2485+
x = f,
2486+
}
2487+
]]
2488+
[[
2489+
local f: A
2490+
]]

0 commit comments

Comments
 (0)