Skip to content

Commit 9364c13

Browse files
committed
fix(Geometry/Manifold/Notation): better error message if the expected type contains metavariables (#35180)
1 parent 9e156ec commit 9364c13

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Mathlib/Geometry/Manifold/Notation.lean

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,13 @@ partial def findModel (e : Expr) (baseInfo : Option (Expr × Expr) := none) : Te
687687
if let some { model .. } ← go e baseInfo then
688688
return model
689689
else
690-
let hint := if (← isTracingEnabledFor `Elab.DiffGeo.MDiff) then m!"" else
691-
.hint' "failures to find a model with corners can be debugged with the \
692-
command `set_option trace.Elab.DiffGeo.MDiff true`."
690+
let tracing := (← isTracingEnabledFor `Elab.DiffGeo.MDiff)
691+
let hint : MessageData := if e.hasExprMVar then
692+
.hint' "the expected type contains metavariables, \
693+
maybe you need to provide an implicit argument"
694+
else if tracing then m!"" else
695+
.hint' "failures to find a model with corners can be debugged with the \
696+
command `set_option trace.Elab.DiffGeo.MDiff true`."
693697
throwError "Could not find a model with corners for `{e}`.{hint}"
694698
where
695699
go (e : Expr) (baseInfo : Option (Expr × Expr)) : TermElabM (Option FindModelResult) := do

MathlibTest/DifferentialGeometry/NotationAdvanced.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ def proj : TangentBundle 𝓘(𝕜, 𝕜) 𝕜 → 𝕜 := fun x ↦ x.2
4646

4747
open ContDiff
4848

49-
-- TODO: the error message could be more helpful, by saying "the goal has metavariables; maybe there is an implicit argument missing"
5049
/--
5150
error: Could not find a model with corners for `TangentBundle 𝓘(?_, ?_) ?_`.
5251
53-
Hint: failures to find a model with corners can be debugged with the command `set_option trace.Elab.DiffGeo.MDiff true`.
52+
Hint: the expected type contains metavariables, maybe you need to provide an implicit argument
5453
-/
5554
#guard_msgs in
5655
set_option pp.mvars.anonymous false in

0 commit comments

Comments
 (0)