From a5febd5cb61d64da662e76c644fc964703fcea83 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Mon, 29 Jan 2024 12:32:06 +0000 Subject: [PATCH] [*] Fix recursive includes --- Core/main.lua | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Core/main.lua b/Core/main.lua index 1012c2a..a2ac68c 100644 --- a/Core/main.lua +++ b/Core/main.lua @@ -9,7 +9,10 @@ _auNamespacesEmitted = {} _auResolvedDep = {} _auCurrentProject = {} _auCurrentBaseProject = nil +_auRefGuardStart = false _auFatalMsg = {} +_auLinkGuard = {} +_auRefGuard = {} ------------------------------------------------------- -- utils @@ -169,8 +172,6 @@ local function pushProject(project, callback) pushProjectState(project.info.name, project.info.path, callback) end -_auLinkGuard = {} - -- private local function processInit(project) if (project.isInitialized) then @@ -267,7 +268,9 @@ local function processNS(namespace) _auFatalMsg["starting projects"] = namespace auForEach(projsIdxs, function(idx) _auLinkGuard = {} - _auLinkGuard[projs[idx].info.name]= {} + _auRefGuard = {} + _auLinkGuard[projs[idx].info.name] = {} + _auRefGuard[projs[idx].info.name] = {} processProject(projs[idx].info.name) end) end @@ -408,12 +411,32 @@ local function includeAuProject(dep, soft) return false end end + + local linkStart = false + if (auGetCurrentProjectMeta()) then + if (_auRefGuard[dep] ) then + return + end + _auRefGuard[dep] = dep + end + + if (not _auRefGuardStart) then + _auRefGuardStart = true + linkStart = true + end + pushProject(a, function() _auFatalMsg["processing project ref"] = a.info.name processor:handleReference(isWeakCircularReference(dep)) _auFatalMsg["processing project ref"] = nil end) + + if (linkStart) then + _auRefGuard = {} + _auRefGuardStart = false + end + return true end