Commits

Anonymous committed 8e25234

Remove infinite loop on MatchGroup without common prefix.

In that case, the exact same MatchGroup would be fed to simplifyTerms again. Now, it is returned immediately, and only the rest of the terms are simplified.

  • Participants
  • Parent commits a599ffb

Comments (0)

Files changed (1)

File System/FilePath/GlobPattern.hs

 simplifyTerms (MatchGroup []:as) = simplifyTerms as
 simplifyTerms (MatchGroup gs:as) =
     case commonPrefix gs of
-    (p,[]) -> simplifyTerms (MatchLiteral p : as)
-    (p,ss) -> simplifyTerms (MatchLiteral p : MatchGroup ss : as)
+    (p ,[]) -> simplifyTerms (MatchLiteral p : as)
+    ("",ss) -> MatchGroup ss : simplifyTerms as
+    (p ,ss) -> simplifyTerms (MatchLiteral p : MatchGroup ss : as)
 simplifyTerms (a:as) = a:simplifyTerms as
 
 commonPrefix :: [String] -> (String, [String])