almost ready for static analysis additions

This commit is contained in:
2026-07-09 19:48:02 -04:00
parent 59903546d7
commit c9b7f8c08b
4 changed files with 96 additions and 21 deletions
+11 -1
View File
@@ -385,7 +385,17 @@ local function topo_sort(passes, requested_set)
end
end
if #order ~= 0 then
-- Cycle detection: if order doesn't include all needed passes,
-- some are stuck with in_degree > 0 (the cycle closed on itself
-- before Kahn could process them). Without this check, a fully-
-- closed cycle (e.g. A -> B -> A) would silently return an empty
-- order list, leaving the orchestrator to dispatch nothing.
--
-- Note: `#needed` returns 0 for hash tables (needed is a set,
-- not a sequence), so we count entries explicitly.
local needed_count = 0
for _ in pairs(needed) do needed_count = needed_count + 1 end
if #order ~= needed_count then
for name, deg in pairs(in_degree) do
if deg > 0 then
error("dependency cycle detected involving pass '" .. name .. "'")