on master help sign in
better fixity error message
commit40ce0cacdcf0796e24c3bf2ac0d4c77ee340b531 authorraichoo <raichoo@googlemail.com> dateMon 19 Nov 2012, 21:22 (14 years ago) parentc9e0444
2 files changed+10−4
src/Idris/AbsSyntaxTree.hs+5−1 src/Idris/Parser.hs+5−3
src/Idris/AbsSyntaxTree.hs+5−1
@@ -231,7 +231,11 @@ instance Show Fixity where
231231 show (PrefixN i) = "prefix " ++ show i
232232
233233data 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+
235239{-!
236240deriving instance Binary FixDecl
237241!-}
src/Idris/Parser.hs+5−3
@@ -486,14 +486,16 @@ pFixity = do pushIndent
486486 istate <- getState
487487 let infixes = idris_infixes istate
488488 let fs = map (Fix (f prec)) ops
489− let redecl = map (alreadyDeclared infixes) fs
490− if False `notElem` map checkValidity redecl
489+ let redecls = map (alreadyDeclared infixes) fs
490+ let ill = filter (not . checkValidity) redecls
491+ if null ill
491492 then do setState (istate { idris_infixes = nub $ sort (fs ++ infixes)
492493 , ibc_write = map IBCFix fs ++ ibc_write istate
493494 })
494495 fc <- pfc
495496 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
497499 where alreadyDeclared :: [FixDecl] -> FixDecl -> (FixDecl, [FixDecl])
498500 alreadyDeclared fs f = (f, filter ((extractName f ==) . extractName) fs)
499501