Skip to content

Commit 738f341

Browse files
committed
#1208 avoid dead cycles
1 parent 767db22 commit 738f341

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

script/vm/infer.lua

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ mt._isLocal = false
2020

2121
vm.NULL = setmetatable({}, mt)
2222

23+
local LOCK = {}
24+
2325
local inferSorted = {
2426
['boolean'] = - 100,
2527
['string'] = - 99,
@@ -218,6 +220,10 @@ function mt:_eraseAlias(uri)
218220
local expandAlias = config.get(uri, 'Lua.hover.expandAlias')
219221
for n in self.node:eachObject() do
220222
if n.type == 'global' and n.cate == 'type' then
223+
if LOCK[n.name] then
224+
goto CONTINUE
225+
end
226+
LOCK[n.name] = true
221227
for _, set in ipairs(n:getSets(uri)) do
222228
if set.type == 'doc.alias' then
223229
if expandAlias then
@@ -239,6 +245,8 @@ function mt:_eraseAlias(uri)
239245
end
240246
end
241247
end
248+
LOCK[n.name] = nil
249+
::CONTINUE::
242250
end
243251
end
244252
return drop

test/type_inference/init.lua

+21
Original file line numberDiff line numberDiff line change
@@ -2491,3 +2491,24 @@ end
24912491
24922492
print(<?x?>)
24932493
]]
2494+
2495+
TEST 'table<unknown, true>' [[
2496+
---@alias xxx table<xxx, true>
2497+
2498+
---@type xxx
2499+
local <?t?>
2500+
]]
2501+
2502+
TEST 'unknown[][]' [[
2503+
---@alias xxx xxx[]
2504+
2505+
---@type xxx
2506+
local <?t?>
2507+
]]
2508+
2509+
TEST 'fun(x: fun(x: unknown))' [[
2510+
---@alias xxx fun(x: xxx)
2511+
2512+
---@type xxx
2513+
local <?t?>
2514+
]]

0 commit comments

Comments
 (0)