Commit graph

12 commits

Author SHA1 Message Date
Kyle Miller
3acd77a154
fix: make elabTermEnsuringType respect errToSorry when there is a type mismatch (#3633)
Floris van Doorn [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/have.20tactic.20error.20recovery/near/425283053)
that it is confusing that the `have : T := e` tactic completely fails if
the body `e` is not of type `T`. This is in contrast to `have : T := by
exact e`, which does not completely fail when `e` is not of type `T`.

This ends up being caused by `elabTermEnsuringType` throwing an error
when it fails to insert a coercion. Now, it detects this case, and it
checks the `errToSorry` flag to decide whether to throw the error or to
log the error and insert a `sorry`.

This is justified by `elabTermEnsuringType` being a frontend to
`elabTerm`, which inserts `sorry` on error.

An alternative would be to make `ensureType` respect `errToSorry`, but
there exists code that expects being able to catch when `ensureType`
fails. Making such code manipulate `errToSorry` seems error prone, and
this function is not a main entry point to the term elaborator, unlike
`elabTermEnsuringType`.
2024-03-09 15:30:47 +00:00
int-y1
9bc6fa1c6e chore: fix typos 2023-03-27 10:05:50 +02:00
Leonardo de Moura
012cb13f51 feat: add [elabAsElim] elaboration strategy 2022-07-28 20:08:29 -07:00
Sebastian Ullrich
e76a2a6d9e chore: normalize spelling 2022-05-03 10:26:11 +02:00
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
Leonardo de Moura
c93982d10c chore: disable pp.analyze for now
see #651
2021-09-07 07:51:43 -07:00
Daniel Selsam
0036111db9 feat: pp.analyze original mvars are not unknown 2021-08-03 09:13:18 +02:00
Daniel Selsam
aefd31b2a2 feat: better bottom-up/structure-type heuristics 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
f47f605039 fix: remove incorrect test
It had two problems:
- It was preventing coercions from being applied.
- It was compromising error recovery. The body of the lambda was not
being elaborated when the exception was thrown.

The new error message is more verbose and potentially confusing, but
it is better than the one produced this morning.
2021-04-24 22:17:29 -07:00
Leonardo de Moura
1f9975d35d feat: improve error message and include variables introduced by the implicit lambda notation 2021-04-24 21:34:42 -07:00
Leonardo de Moura
10185d24dd feat: improve error message 2021-04-24 20:43:13 -07:00