This issue produced a nested inductive datatype that could not be
handled by the kernel. See new test.
Without the fix, the inductive declaration contained the term
```
((fun α {n : Nat} (t : Vec α n) => ...) Expr n x)
```
The nested occurrence `Vec Expr n` only becomes explicit after
beta-reduction.
This issue exposed two bugs at `Structural.lean`
1- `getFixedPrefix` was using structural equality to detected fixed
arguments. We should use definitional equality.
2- The `replaceFVars` was broken. We should use `instantiateForall` instead.
We now (try to) postpone `match ... with` elaboration when pattern
variables and patterns still contain metavariables before invoking `mkMatcher`.
This improvement makes sure we can elaborate an example submitted by
Daniel Selsam.
Remark: this update may create performance problems since we
backtrack `elabMatchTypeAndDiscrs` and `elabMatchAltView`.
We hope this is not a problem in practice since we use the "quick-check"
`waitExpectedTypeAndDiscrs`. Recall that we could compile Lean
without this commit. So, it suggests cases where we need to postpone
after `elabMatchAltView` are rare.
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