File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,17 @@ function mt:resolve(uri, args)
3030
3131 ---@type table<string, vm.node>
3232 local resolved = {}
33+ ---@type table<string, boolean>
34+ local resolving = {}
3335
3436 ---@param object vm.node|vm.node.object
3537 ---@param node vm.node
3638 local function resolve(object, node)
39+ local resolveHash = ("%s|%s"):format(object, node)
40+ if resolving[resolveHash] then
41+ return -- prevent circular resolve calls
42+ end
43+ resolving[resolveHash] = true
3744 if object.type == 'vm.node' then
3845 for o in object:eachObject() do
3946 resolve(o, node)
Original file line number Diff line number Diff line change @@ -4881,3 +4881,25 @@ end
48814881
48824882local a, b, <?c?>, d = unpack(t)
48834883]]
4884+
4885+ -- Test for overflow in circular resolve, only pass requirement is no overflow
4886+ TEST 'Callback<<T>>|fun():fun():fun():Success, string' [[
4887+ --- @alias Success fun(): Success
4888+ --- @alias Callback<T> fun(): Success, T
4889+
4890+ --- @return Success
4891+ local function success()
4892+ return success
4893+ end
4894+
4895+ --- @generic T
4896+ --- @param callback Callback<T>
4897+ --- @return Callback<T>
4898+ local function make_callback(callback)
4899+ return callback
4900+ end
4901+
4902+ local <?callback?> = make_callback(function()
4903+ return success, ""
4904+ end)
4905+ ]]
You can’t perform that action at this time.
0 commit comments