import action for out of scope names, start introducing error types
Some checks failed
Publish Playground / build (push) Has been cancelled
Publish Playground / deploy (push) Has been cancelled

This commit is contained in:
2026-02-24 09:33:53 -08:00
parent 134c9f11db
commit ccdb15c6ec
5 changed files with 59 additions and 46 deletions

View File

@@ -1535,9 +1535,6 @@ infer ctx tm@(RUpdateRec fc _ _) = error fc "I can't infer record updates"
infer ctx (RVar fc nm) = go 0 ctx.types
where
entryNS : TopEntry String
entryNS (MkEntry fc (QN ns _) _ _ _) = ns
go : Int -> List (String × Val) -> M (Tm × Val)
go i Nil = do
top <- getTop
@@ -1546,13 +1543,8 @@ infer ctx (RVar fc nm) = go 0 ctx.types
debug $ \ _ => "lookup \{show name} as \{show def}"
vty <- eval Nil ty
pure (Ref fc name, vty)
Nothing => do
let mods = map entryNS $ lookupAll nm top
let extra = case mods of
Nil => ""
-- For the benefit of the editor, but only sees transitive modules
_ => ", try importing: \{joinBy ", " mods}"
error fc "\{show nm} not in scope\{extra}"
-- Can we soften this without introducing a meta?
Nothing => throwError $ ENotFound fc nm
go i ((x, ty) :: xs) = if x == nm then pure (Bnd fc i, ty)
else go (i + 1) xs