fix env (should have used an index...)

This commit is contained in:
2025-07-10 13:43:57 -04:00
parent cee1519b8e
commit 9bd9ab21b6
5 changed files with 86 additions and 8 deletions

View File

@@ -54,7 +54,7 @@ dumpCtx : Context -> M String
dumpCtx ctx = do
let names = (map fst ctx.types)
-- I want to know which ones are defines. I should skip the `=` bit if they match, I'll need indices in here too.
env <- for (zip ctx.env ctx.types) $ \case
env <- for (reverse $ zip ctx.env ctx.types) $ \case
(v, n, ty) => do
sty <- vprint ctx ty
sv <- vprint ctx v
@@ -697,7 +697,7 @@ getConstructors ctx scfc (VRef fc nm _) = do
top <- getTop
case lookup nm top of
(Just (MkEntry _ name type (TCon _ names) _)) => pure names
_ => error scfc "Not a type constructor \{show nm}"
_ => error scfc "Not a type constructor: \{show nm}"
lookupDCon : QName -> M (QName × Int × Tm)
lookupDCon nm = do
top <- getTop

View File

@@ -74,7 +74,7 @@ tryEval env (VRef fc k sp) = do
catchError (
do
debug $ \ _ => "app \{show name} to \{show sp}"
vtm <- eval Nil CBN tm
vtm <- eval env CBN tm
debug $ \ _ => "tm is \{render 90 $ pprint Nil tm}"
val <- vappSpine vtm sp
case val of
@@ -86,7 +86,9 @@ tryEval env (VRef fc k sp) = do
VLetRec _ _ _ _ _ => pure Nothing
v => pure $ Just v)
(\ _ => pure Nothing)
_ => pure Nothing
_ => do
debug $ \ _ => "tryEval blocked on undefined \{show k}"
pure Nothing
tryEval _ _ = pure Nothing

View File

@@ -178,6 +178,7 @@ pprint' p names (Bnd _ k) = case getAt (cast k) names of
pprint' p names (Ref _ str) = text (show str)
pprint' p names (Meta _ k) = text "?m:\{show k}"
pprint' p names (Lam _ nm icit quant t) = parens 0 p $ nest 2 $ text "\\ \{show quant}\{nm} =>" <+/> pprint' 0 (nm :: names) t
-- FIXME - we've lost icity, so we implict app as normal
pprint' p names (App _ t u) = parens 0 p $ pprint' 0 names t <+> pprint' 1 names u
pprint' p names (UU _) = text "U"
pprint' p names (Pi _ nm Auto rig t u) = parens 0 p $