diff --git a/src/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean b/src/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean index 9992786920..ec3f0d6667 100644 --- a/src/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean +++ b/src/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean @@ -321,10 +321,12 @@ partial def analyze (parentIsApp : Bool := false) : AnalyzeM Unit := do | Expr.bvar .. => pure () where analyzeApp := do - withKnowing true true $ analyzeAppStaged (← getExpr).getAppFn (← getExpr).getAppArgs + let couldBottomUp ← canBottomUp (← getExpr) + withReader (fun ctx => { ctx with inBottomUp := ctx.inBottomUp || (!ctx.knowsType && couldBottomUp) }) do + withKnowing true true $ analyzeAppStaged (← getExpr).getAppFn (← getExpr).getAppArgs if !(← read).knowsType then - if !(← canBottomUp (← getExpr)) then + if !couldBottomUp then annotateBool `pp.analysis.needsType withType $ withKnowing true false $ analyze else diff --git a/tests/lean/run/PPTopDownAnalyze.lean b/tests/lean/run/PPTopDownAnalyze.lean index c164af7615..0a451215d7 100644 --- a/tests/lean/run/PPTopDownAnalyze.lean +++ b/tests/lean/run/PPTopDownAnalyze.lean @@ -245,6 +245,12 @@ structure S2 where x : Unit #testDelab (fun (u : Unit) => { x := () : S2 }) () expecting (fun (u : Unit) => { x := () : S2 }) () +#testDelab Eq.refl True + expecting Eq.refl _ + +#testDelab (fun (u : Unit) => Eq.refl True) () + expecting (fun (u : Unit) => Eq.refl True) () + #testDelabN Nat.brecOn #testDelabN Nat.below #testDelabN Nat.mod_lt