on master help sign in
better fixity error message
40ce0caraichoo
src/Idris/AbsSyntaxTree.hs+5−1
@@ -231,7 +231,11 @@ instance Show Fixity where
231 show (PrefixN i) = "prefix " ++ show i
231 show (PrefixN i) = "prefix " ++ show i
232
232
233data FixDecl = Fix Fixity String
233data FixDecl = Fix Fixity String
234− deriving (Show, Eq)
234+ deriving Eq
235+
236+instance Show FixDecl where
237+ show (Fix f s) = show f ++ " " ++ s
238+
235{-!
239{-!
236deriving instance Binary FixDecl
240deriving instance Binary FixDecl
237!-}
241!-}
src/Idris/Parser.hs+5−3
@@ -486,14 +486,16 @@ pFixity = do pushIndent
486 istate <- getState
486 istate <- getState
487 let infixes = idris_infixes istate
487 let infixes = idris_infixes istate
488 let fs = map (Fix (f prec)) ops
488 let fs = map (Fix (f prec)) ops
489− let redecl = map (alreadyDeclared infixes) fs
489+ let redecls = map (alreadyDeclared infixes) fs
490− if False `notElem` map checkValidity redecl
490+ let ill = filter (not . checkValidity) redecls
491+ if null ill
491 then do setState (istate { idris_infixes = nub $ sort (fs ++ infixes)
492 then do setState (istate { idris_infixes = nub $ sort (fs ++ infixes)
492 , ibc_write = map IBCFix fs ++ ibc_write istate
493 , ibc_write = map IBCFix fs ++ ibc_write istate
493 })
494 })
494 fc <- pfc
495 fc <- pfc
495 return (PFix fc (f prec) ops)
496 return (PFix fc (f prec) ops)
496− else fail "Illegal redeclaration of fixity"
497+ else fail $ concatMap (\(f, (x:xs)) -> "Illegal redeclaration of fixity: \""
498+ ++ show f ++ "\" overrides \"" ++ show x ++ "\"\n") ill
497 where alreadyDeclared :: [FixDecl] -> FixDecl -> (FixDecl, [FixDecl])
499 where alreadyDeclared :: [FixDecl] -> FixDecl -> (FixDecl, [FixDecl])
498 alreadyDeclared fs f = (f, filter ((extractName f ==) . extractName) fs)
500 alreadyDeclared fs f = (f, filter ((extractName f ==) . extractName) fs)
499
501