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.
This commit is contained in:
Erik Hesselink 2012-04-17 14:02:05 +02:00
parent 3d3f70619c
commit 59fafe0596
1 changed files with 3 additions and 2 deletions

View File

@ -117,8 +117,9 @@ simplifyTerms (MatchClass True (SRange a@[_] []):as) =
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])