improve already defined error messages

This commit is contained in:
2024-12-22 14:58:45 -08:00
parent e0c75ff487
commit ad2f29d0af
3 changed files with 4 additions and 8 deletions

View File

@@ -207,7 +207,7 @@ processDecl (TypeSig fc names tm) = do
let mstart = length mc.metas
for_ names $ \nm => do
let Nothing := lookup nm top
| _ => error fc "\{show nm} is already defined"
| Just entry => error fc "\{show nm} is already defined at \{show entry.fc}"
pure ()
ty <- check (mkCtx fc) tm (VU fc)
ty <- zonk top 0 [] ty
@@ -241,7 +241,7 @@ processDecl (Def fc nm clauses) = do
let Just entry = lookup nm top
| Nothing => throwError $ E fc "No declaration for \{nm}"
let (MkEntry fc name ty Axiom) := entry
| _ => throwError $ E fc "\{nm} already defined"
| _ => throwError $ E fc "\{nm} already defined at \{show entry.fc}"
putStrLn "check \{nm} at \{pprint [] ty}"
vty <- eval empty CBN ty

View File

@@ -45,8 +45,8 @@ setDef name fc ty def = do
where
go : List TopEntry -> M (List TopEntry)
go [] = pure $ [MkEntry fc name ty def]
go (x@(MkEntry _ nm ty' def') :: defs) = if nm == name
then error fc "\{name} is already defined"
go (x@(MkEntry fc' nm ty' def') :: defs) = if nm == name
then error fc "\{name} is already defined at \{show fc'}"
else (x ::) <$> go defs
public export