Commit graph

6 commits

Author SHA1 Message Date
Leonardo de Moura
40c8db7494 feat: improve argument type mismatch error position, and do not stop at application type mismatch errors 2022-04-25 16:30:40 -07:00
Daniel Selsam
0036111db9 feat: pp.analyze original mvars are not unknown 2021-08-03 09:13:18 +02:00
Daniel Selsam
c3d62c1076 chore: patch tests for pp.analyze default 2021-08-03 09:13:18 +02:00
Leonardo de Moura
5d3f0606d2 feat: include type of type in "mismatch errors"
@Kha we do that in Lean 3. It helps when the error is due to incorrect universe levels.

BTW, I had to update `tests/lean/server/content_diag.json` since the
error message is different, but a few other stuff changed too.
Could you please take a look whether the test is still correct?
2021-03-08 09:30:34 -08:00
Sebastian Ullrich
b2b78eb222 test: use printMessageEndPos for leantests 2021-01-15 16:27:59 +01:00
Leonardo de Moura
7a4b544b1c feat: improve application type mismatch error message
If the type error is at an implicit argument, we annotate
application with `pp.explicit := true`

Given the type incorrect definition
```
def f {a b c : α} : a = c :=
  Eq.trans (a := a) (b := b = c)
```
We now generate the error
```
error: application type mismatch
  @Eq.trans α a (b = c)
argument
  b = c
has type
  Prop
but is expected to have type
  α
```
@Kha Note that we only enable `pp.explicit := true` for the relevant
application. That is, we set `pp.explicit := false` for each children.

Unfortunately, there is a corner case.
```
set_option pp.explicit true
def f {a b c : α} : a = c :=
  Eq.trans (a := a) (b := b = c)
```
produces the error
```
error: application type mismatch
  @Eq.trans α a (b = c)
argument
  @Eq α b c
has type
  Prop
but is expected to have type
  α
```
The reset `pp.explicit := false` overwrote the user option.
I think the simplest solution is the following
1- The delaborator saves the initial set of Options `Init`
2- When it finds a node annotated with a `pp` options, it only
consider the option if it is not set by `Init`.

What do you think?
2020-12-09 13:58:08 -08:00