Rehydrate binder names during quoting so diagnostics stop hemorrhaging raw de bruijn indices

This commit is contained in:
2026-04-19 14:22:34 +00:00
parent 85be37b1d6
commit bb002a4d92
2 changed files with 100 additions and 24 deletions
+26 -1
View File
@@ -148,10 +148,35 @@ def runInternalSafetyChecks : IO Bool := do
IO.println "FAIL malformed core terms are rejected safely"
pure false
def runPrettyPrinterChecks : IO Bool := do
match checkTop Examples.idAnn with
| .ok (tm, ty) =>
match renderType ty with
| Except.ok qty =>
let termText := BidirTT.prettyTm tm
let typeText := BidirTT.prettyTm qty
let ok :=
containsText termText "fun x0 =>" &&
containsText typeText "Pi (x0 : U0)" &&
!containsText typeText "#"
if ok then
IO.println "PASS pretty printer rehydrates binder names"
pure true
else
IO.println s!"FAIL pretty printer rehydrates binder names (term: {termText}, type: {typeText})"
pure false
| Except.error err =>
IO.println s!"FAIL pretty printer rehydrates binder names (could not quote type: {err})"
pure false
| .error err =>
IO.println s!"FAIL pretty printer rehydrates binder names (could not elaborate fixture: {err})"
pure false
def main : IO UInt32 := do
let results cases.mapM runCase
let safetyOk runInternalSafetyChecks
let allResults := results ++ [safetyOk]
let prettyOk runPrettyPrinterChecks
let allResults := results ++ [safetyOk, prettyOk]
let failed := allResults.countP (· == false)
if failed == 0 then
IO.println s!"\n{allResults.length} passed, 0 failed"