on master help sign in
also fix duplicate *type* constructors
commit55e5c342ce415eb541d85940875ae4f64913c27b authorBen Darwin <ben@localhost.localdomain> dateTue 10 Dec 2013, 16:36 (13 years ago) parent36b73fe
1 file changed+8−5
compiler/Transform/Check.hs+8−5
compiler/Transform/Check.hs+8−5
@@ -17,7 +17,7 @@ mistakes :: (Data t, Data v) => [Declaration t v] -> [Doc]
1717mistakes decls =
1818 concat [ infiniteTypeAliases decls
1919 , illFormedTypes decls
20− , map P.text (duplicateDataConstructors decls)
20+ , map P.text (duplicateConstructors decls)
2121 , map P.text (concatMap findErrors (getLets decls)) ]
2222 where
2323 findErrors defs = duplicates defs ++ badOrder defs
@@ -47,12 +47,15 @@ duplicates defs =
4747 defMsg x = msg ++ "definition of '" ++ x ++ "'."
4848 annMsg x = msg ++ "type annotation for '" ++ x ++ "'."
4949
50−duplicateDataConstructors :: [Declaration t v] -> [String]
51−duplicateDataConstructors decls = map ctorMsg . dups $ constructors
50+duplicateConstructors :: [Declaration t v] -> [String]
51+duplicateConstructors decls =
52+ map typeMsg (dups typeCtors) ++ map dataMsg (dups dataCtors)
5253 where
53− constructors = List.sort . concat $
54+ typeCtors = List.sort [ name | Datatype name _ _ <- decls ]
55+ dataCtors = List.sort . concat $
5456 [ map fst patterns | Datatype _ _ patterns <- decls ]
55− ctorMsg x = msg ++ "definition of '" ++ x ++ "'."
57+ dataMsg x = msg ++ "definition of data constructor '" ++ x ++ "'."
58+ typeMsg x = msg ++ "definition of type constructor '" ++ x ++ "'."
5659
5760badOrder :: [Def t v] -> [String]
5861badOrder defs = go defs