From e61f2f8d035e4a10e02ffaa259514273185ef172 Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 28 Feb 2013 17:46:13 +0000 Subject: [PATCH] Fix a bug that could cause "Prelude.head: empty list" In Data.Operations, the function topoTest2 assumed too much about the form of the input, compared to the older function topoTest. --- src/compiler/GF/Data/Operations.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/GF/Data/Operations.hs b/src/compiler/GF/Data/Operations.hs index 366f5a669..b70df6a90 100644 --- a/src/compiler/GF/Data/Operations.hs +++ b/src/compiler/GF/Data/Operations.hs @@ -266,8 +266,10 @@ topoTest = topologicalSort . mkRel' -- | topological sorting with test of cyclicity, new version /TH 2012-06-26 topoTest2 :: Ord a => [(a,[a])] -> Either [[a]] [[a]] -topoTest2 g = maybe (Right cycles) Left (tsort g) +topoTest2 g0 = maybe (Right cycles) Left (tsort g) where + g = g0++[(n,[])|n<-nub (concatMap snd g0)\\map fst g0] + cycles = findCycles (mkRel' g) tsort nes =