Skip to content

Commit e838c0c

Browse files
committed
fix: panic in ProofMode/Delab
1 parent fb7129a commit e838c0c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Lean/Elab/Tactic/Do/ProofMode/Delab.lean

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ open Lean Expr Meta PrettyPrinter Delaborator SubExpr
1919
@[builtin_delab app.Std.Tactic.Do.MGoalEntails]
2020
private partial def delabMGoal : Delab := do
2121
-- delaborate
22-
let (_, _, hyps) ← withAppFn ∘ withAppArg <| delabHypotheses ({}, {}, #[])
22+
-- FIXME: sometimes this is called on expressions which do not have two arguments.
23+
-- e.g. observed in doc-gen4, `← getExpr` can be `Std.Tactic.Do.MGoalEntails.{?_uniq.32}`.
24+
-- For now, we add a guard that just abandons delaboration if there aren't two arguments.
25+
guard <| (← getExpr).getAppNumArgs >= 2
26+
let (_, _, hyps) ← withAppFn <| withAppArg <| delabHypotheses ({}, {}, #[])
2327
let target ← SPred.Notation.unpack (← withAppArg <| delab)
2428

2529
-- build syntax
@@ -58,7 +62,7 @@ where
5862
return (accessibles, inaccessibles, lines.push stx)
5963
if (parseAnd? hyps).isSome then
6064
let acc_rhs ← withAppArg <| delabHypotheses acc
61-
let acc_lhs ← withAppFn withAppArg <| delabHypotheses acc_rhs
65+
let acc_lhs ← withAppFn <| withAppArg <| delabHypotheses acc_rhs
6266
return acc_lhs
6367
else
6468
failure

0 commit comments

Comments
 (0)