lean4-htt/tests/lean/safeShadowing.lean
Leonardo de Moura f73eb1246a feat: add pp.safe_shadowing
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
2021-01-15 18:53:25 -08:00

22 lines
309 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def f (x x : Nat) :=
match x with
| 0 => x + 1
| Nat.succ _ => x + 2
variables {α : Type}
#check fun (a : α) => a
#check fun {α} (a : α) => a
#check fun (x x : Nat) => x
#print f
set_option pp.safe_shadowing false
#check fun {α} (a : α) => a
#check fun (x x : Nat) => x
#print f