Skip to content

Commit de694f3

Browse files
author
Hackworth Ltd Claude Code
committed
fix: reduce type-level let (TLet) RHS in the interpreter
`interpTy` bound the right-hand side of a type-level `tlet` into the type environment unevaluated, while the `TVar` lookup returns stored values verbatim -- relying on them being normal forms. Every other binding site (term-level `Let`, `LetType`, `BETA`/`APP`, the `Case` argument types, and `TForall`) already interprets its RHS first; `TLet` was the lone exception. Interpret the RHS before binding it. This is safe and terminating, since type evaluation always terminates. It fixes both witnesses from the previous commit: type-level `let`s now fully reduce instead of leaving a dangling out-of-scope variable or residual `tlet`s. Fixes #1439.
1 parent b4aed7e commit de694f3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

primer/src/Primer/EvalFullInterp.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,11 @@ interpTy env = \case
380380
TForall _ v k t ->
381381
let v' = freshLikeTy v env
382382
in TForall () v' k (interpTy (extendTyEnv' v (TVar () v') env) t)
383-
TLet _ v s t -> interpTy (extendTyEnv' v s env) t
383+
-- We must reduce the RHS before binding it, just as every other binding site
384+
-- does: the 'TVar' case returns stored values verbatim, relying on the
385+
-- environment holding normal forms. (Type evaluation always terminates, so
386+
-- this cannot loop.)
387+
TLet _ v s t -> interpTy (extendTyEnv' v (interpTy env s) env) t
384388

385389
extendTmEnv ::
386390
Either GVarName LVarName ->

0 commit comments

Comments
 (0)