Where before we had ```lean #check fun x : Nat => ?a -- fun x ↦ ?m.7 x : (x : Nat) → ?m.6 x ``` Now by default we have ```lean #check fun x : Nat => ?a -- fun x => ?a : (x : Nat) → ?m.6 x ``` In particular, delayed assignment metavariables such as `?m.7` pretty print using the name of the metavariable they are delayed assigned to, suppressing the bound variables used in the delayed assignment (hence `?a` rather than `?a x`). Hovering over `?a` shows `?m.7 x`. The benefit is that users can see the user-provided name in local contexts. A justification for this pretty printing choice is that `?m.7 x` is supposed to stand for `?a`, and furthermore it is just as opaque to assignment in defeq as `?a` is (however, when synthetic opaque metavariables are made assignable, delayed assignments can be a little less assignable than true synthetic opaque metavariables). The original pretty printing behavior can be recovered using `set_option pp.mvars.delayed true`. This PR also extends the documentation for holes and synthetic holes, with some technical details about what delayed assignments are. This likely should be moved to the reference manual, but for now it is included in this docstring. (This PR is a simplified version of #3494, which has a round-trippable notation for delayed assignments. The pretty printing in this PR is unlikely to round trip, but it is better than the current situation, which is that delayed assignment metavariables never round trip, and plus it does not require introducing a new notation.)
46 lines
997 B
Text
46 lines
997 B
Text
set_option pp.mvars false
|
|
|
|
structure Foo := (n : Nat)
|
|
|
|
def Foo.sum (xs : List Foo) : Foo :=
|
|
xs.foldl (λ s x => ⟨s.n + x.n⟩) ⟨0⟩
|
|
|
|
/--
|
|
info: let x1 := { n := 1 };
|
|
let x2 := { n := 2 };
|
|
let x3 := { n := 3 };
|
|
let x5 := { n := 5 };
|
|
let x6 := { n := 6 };
|
|
Foo.sum [x1, x2, x3, x5, x6] : Foo
|
|
-/
|
|
#guard_msgs in
|
|
#check
|
|
let x1 := ⟨1⟩
|
|
let x2 := ⟨2⟩
|
|
let x3 := ⟨3⟩
|
|
-- let x4 := ⟨4⟩; -- If this line is uncommented we get the error at `⟨`
|
|
let x5 := ⟨5⟩
|
|
let x6 := ⟨6⟩
|
|
Foo.sum [x1, x2, x3, x5, x6]
|
|
|
|
/--
|
|
error: invalid constructor ⟨...⟩, expected type must be an inductive type ⏎
|
|
?_
|
|
---
|
|
info: let x1 := { n := 1 };
|
|
let x2 := { n := 2 };
|
|
let x3 := { n := 3 };
|
|
let x4 := ?_;
|
|
let x5 := { n := 5 };
|
|
let x6 := { n := 6 };
|
|
Foo.sum [x1, x2, x3, x5, x6] : Foo
|
|
-/
|
|
#guard_msgs in
|
|
#check
|
|
let x1 := ⟨1⟩
|
|
let x2 := ⟨2⟩
|
|
let x3 := ⟨3⟩
|
|
let x4 := ⟨4⟩; -- If this line is uncommented we get the error at `⟨`
|
|
let x5 := ⟨5⟩
|
|
let x6 := ⟨6⟩
|
|
Foo.sum [x1, x2, x3, x5, x6]
|