Skip to content

Commit

Permalink
fix: Second miss-handling of free variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hargoniX committed Oct 17, 2023
1 parent bc9cba1 commit 0f1b99c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions DocGen4/Process/DefinitionInfo.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ namespace DocGen4.Process

open Lean Meta Widget

partial def stripArgs (e : Expr) : Expr :=
partial def stripArgs (e : Expr) (k : Expr → MetaM α) : MetaM α :=
match e.consumeMData with
| Expr.forallE name _ body _ =>
| Expr.forallE name type body bi =>
let name := name.eraseMacroScopes
stripArgs (Expr.instantiate1 body (mkFVar ⟨name⟩))
| _ => e
Meta.withLocalDecl name bi type fun fvar => do
stripArgs (Expr.instantiate1 body fvar) k
| _ => k e

def valueToEq (v : DefinitionVal) : MetaM Expr := withLCtx {} {} do
withOptions (tactic.hygienic.set . false) do
Expand All @@ -29,8 +30,7 @@ def valueToEq (v : DefinitionVal) : MetaM Expr := withLCtx {} {} do

def processEq (eq : Name) : MetaM CodeWithInfos := do
let type ← (mkConstWithFreshMVarLevels eq >>= inferType)
let final := stripArgs type
prettyPrintTerm final
stripArgs type prettyPrintTerm

def DefinitionInfo.ofDefinitionVal (v : DefinitionVal) : MetaM DefinitionInfo := do
let info ← Info.ofConstantVal v.toConstantVal
Expand All @@ -49,7 +49,7 @@ def DefinitionInfo.ofDefinitionVal (v : DefinitionVal) : MetaM DefinitionInfo :=
isNonComputable
}
| none =>
let equations := #[← prettyPrintTerm <| stripArgs (← valueToEq v)]
let equations := #[← stripArgs (← valueToEq v) prettyPrintTerm]
return {
toInfo := info,
isUnsafe,
Expand Down

0 comments on commit 0f1b99c

Please sign in to comment.