From 33ab33d4c8f34743202e5acbfb2e976ab3070299 Mon Sep 17 00:00:00 2001 From: InversionSpaces Date: Fri, 14 Jul 2023 14:06:21 +0200 Subject: [PATCH] fix(compiler): Fix search for one element cycles (#797) --- linker/src/main/scala/aqua/linker/Linker.scala | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/linker/src/main/scala/aqua/linker/Linker.scala b/linker/src/main/scala/aqua/linker/Linker.scala index 5afdbd25..6d71b6ea 100644 --- a/linker/src/main/scala/aqua/linker/Linker.scala +++ b/linker/src/main/scala/aqua/linker/Linker.scala @@ -40,12 +40,10 @@ object Linker extends Logging { case path :: otherPaths => val pathDeps = deps.get(path.last).toList.flatten val cycles = pathDeps.flatMap(dep => - NonEmptyChain - .fromChain( - // This is slow - path.toChain.dropWhile(_ != dep) - ) - .toList + NonEmptyChain.fromChain( + // This is slow + path.toChain.dropWhile(_ != dep) + ) ) val newPaths = pathDeps .filterNot(visited.contains) @@ -62,7 +60,7 @@ object Linker extends Logging { .flatMap(m => findCycles( paths = NonEmptyChain.one(m.id) :: Nil, - visited = Set.empty, + visited = Set(m.id), result = List.empty ) )