Commit graph

22 commits

Author SHA1 Message Date
Leonardo de Moura
1e44902243 fix: add withFreshMacroScope at expandMacroImpl? 2021-10-02 16:57:25 -07:00
Sebastian Ullrich
a993e0baa0 fix: non-dependent arrow should not extend local context 2021-06-29 06:31:37 -07:00
Leonardo de Moura
05022cc80b fix: disable implicit lambda insertion at _, ?h, and by ...
@Kha This commit addresses an issue reported by Kevin. Holes and tactic
blocks represent a discontinuity in the elaboration process.
By introducing inaccessible variables (or "things" as Kevin calls
them), we create error message that are harder to understand (see
affected test), and goals where we didn't allow the user to select the
variable name and/or eagerly unfolded a definition.

BTW, I first considered using "reducible" setting when deciding
whether to insert implicit lambdas or not. This is a bad idea.
See `monotone.lean` test. The decision should not depend on
reducibility status, but whether there is "discontinuity" on the
elaboration process or not. As Kevin pointed out,
"introducing implicits work great if you finish the job".
2021-03-25 16:13:15 -07: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
760b658d19 chore: suppress extraMsg in type mismatch errors 2020-10-06 10:58:50 -07:00
Leonardo de Moura
0ce6ac4267 chore: fix error messages 2020-10-06 10:52:04 -07:00
Leonardo de Moura
02e6f019c4 refactor: move nextMacroScope to Core.State
@Kha We now can create scoped user-facing names at `CoreM` and `MetaM`
methods.
2020-09-18 12:00:24 -07:00
Leonardo de Moura
e9d65dd2de chore: improve sanitizeNames superscripts
cc @Kha
2020-09-17 08:57:54 -07:00
Sebastian Ullrich
26ed304071 fix: pretty print simplified macro scopes 2020-09-17 17:13:50 +02:00
Sebastian Ullrich
3834a89cdc feat: activate new pretty printer 2020-09-17 08:12:28 -07:00
Leonardo de Moura
9f5e63cd3c feat: add option pp.macroStack
@Kha I set it to `false` by default.
2020-09-16 15:29:28 -07:00
Leonardo de Moura
965a989dc2 fix: must log at evalCommand
Some macros expand a command into multiple commands. We should not
interrupt the elaboration of the command sequence when one fails.
2020-09-16 14:55:58 -07:00
Leonardo de Moura
751db760d5 fix: sanitizeNames
A macro scoped name cannot shadow a name without macro scopes.
2020-09-16 13:54:30 -07:00
Leonardo de Moura
e10cd085f4 feat: use sanitizeNames at ppGoal 2020-09-16 13:39:06 -07:00
Leonardo de Moura
16ec9db1fc chore: fix test 2020-09-16 13:12:00 -07:00
Leonardo de Moura
19a7927f10 feat: sanitizeNames
@Kha I am using `_shadowed.<idx>` suffix for marking variables that
have been shadowed. It is a bit verbose, but at least it is easy to
understand understand error messages such as
```
shadow.lean:4:0: error: type mismatch
  h
has type
  x._shadowed.1 = x._shadowed.1
but it is expected to have type
  x = x
```
It is better than the old cryptic version
```
shadow.lean:4:0: error: type mismatch
  h
has type
  x = x
but it is expected to have type
  x = x
```
2020-09-15 16:28:50 -07:00
Leonardo de Moura
6234c60aae chore(*): disable test suite 2018-04-10 12:56:55 -07:00
Leonardo de Moura
1e6b3614ab feat(frontends/lean): new pattern matching validation
@Kha, we now support variable/constant shadowing in patterns.
A constant may occur in a pattern if it is a constructor or tagged with
the new [pattern] attribute. In the standard library, I have tagged
'add', 'zero', 'one', 'bit0', 'bit1' and 'rfl' with this new attribute.
BTW, arbitrary constants and variables may occur nested in type ascriptions and
inaccessible terms.

Here is an example:

     meta_definition tactic_result_to_string {A : Type} : tactic_result A → string
     | (success a s)   := to_string a
     | (exception ⌞A⌟ e s) := "Exception: " ++ to_string (e ())

I had to use the inaccessible ⌞A⌟ in the example above, otherwise, we would be shadowing the parameter
{A : Type}, and we would get a type error.

The new validation is performed at to_pattern_fn (parser.cpp).
2016-08-07 11:31:11 -07:00
Leonardo de Moura
eb526be99f chore(tests/lean): adjust tests 2016-07-22 11:34:58 -07:00
Leonardo de Moura
5ca52d81ec feat(frontends/lean): ML-like notation for match and recursive equations 2015-02-25 16:20:44 -08:00
Leonardo de Moura
a3bc1b0cd5 fix(library/definitional/equations): add more equation validation to avoid obscure error message 2015-01-09 18:52:21 -08:00