When `pp.safe_shadowing` is set to true, we still use the
suggested name if the "body" does not contain a free variable with the
suggested name. This is the approach used in Lean 3, and I think it
improved the result in all affected tests.
The implementation was simple. The only nasty case was `delabAppMatch`.
The main motivation for this feature was hovering information such as
```lean
f : {α_1 : Type} → α_1 → α_1
```
when hovering over the `f` at
```lean
def g (α : Type) (a : α) :=
f a
```
With `safe_shadowing`, we get the nicer
```lean
f : {α : Type} → α → α
```
cc @Kha
15 lines
484 B
Text
15 lines
484 B
Text
fun (a : α) => a : α → α
|
||
fun {α : Sort u_1} (a : α) => a : {α : Sort u_1} → α → α
|
||
fun (x x : Nat) => x : Nat → Nat → Nat
|
||
def f : Nat → Nat → Nat :=
|
||
fun (x x : Nat) =>
|
||
match x with
|
||
| 0 => x + 1
|
||
| Nat.succ x_1 => x + 2
|
||
fun {α_1 : Sort u_1} (a : α_1) => a : {α_1 : Sort u_1} → α_1 → α_1
|
||
fun (x x_1 : Nat) => x_1 : Nat → Nat → Nat
|
||
def f : Nat → Nat → Nat :=
|
||
fun (x x_1 : Nat) =>
|
||
match x_1 with
|
||
| 0 => x_1 + 1
|
||
| Nat.succ x_2 => x_1 + 2
|