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

@@ -80,10 +80,6 @@ step mach@(M a b c mem ip out) =
combo 6 = c combo 6 = c
combo n = itobi n combo n = itobi n
find : a. (a Bool) List a Maybe a
find f Nil = Nothing
find f (x :: xs) = if f x then Just x else find f xs
Cand : U Cand : U
Cand = BigInt × SnocList Int × List Int Cand = BigInt × SnocList Int × List Int

View File

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

View File

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