Commit graph

376 commits

Author SHA1 Message Date
Leonardo de Moura
7cdf917c97 fix: compiler do a; b as a >>= fun _ => b
Consider the following example
```lean
def div!: Nat → Nat → Nat
| x, 0 => panic! "division by zero"
| x, y => x/y

def weird (x : Nat) : MetaM Nat :=
unless (x > 0) (throwOther "x == 0") *>
let y := div! 10 x;
pure y
```
If we execute `weird 0`, it produces a "division by zero" panic
message.
This is a simple version of a much bigger function in the new
frontend.
This is not due to a bug in the compiler.
It produces the panic message because of the `do`-encoding
refactoring. Recall that, a few months ago,
we started to compile `do a; b` as `a *> b` (i.e., `seqRight a b`).
Thus, the example above is
`seqRight action1 (let y := div! 10 x; pure y)`
where `action1` is the `unless ...`.
In A-normal form, this is equivalent to

```lean
let y:= div! 10 x;
let action2 := pure y;
seqRight action1 action2
```
Thus, we execute `div! 10 x` before we even execute the `seqRight`.
This is counterintuitive and demonstrates once again how impure
features such as `panic!` are dangerous.

This commit reverts the `do`-encoding refactoring, and encodes
`do a; b` as `a >>= fun _ b` as we did in Lean3.

cc @Kha
2020-08-15 15:51:00 -07:00
Leonardo de Moura
1307405300 chore: make sure parser! and tparser! use a syntax similar to the one used at syntax for setting precedences
cc @Kha
2020-06-10 16:09:13 -07:00
Leonardo de Moura
cdc2dbe28d chore: use leadingNode and trailingNode in the old frontend 2020-06-10 15:05:22 -07:00
Leonardo de Moura
ca018d561e chore: update parser! and tparser! macros in the old frontend 2020-06-10 14:39:33 -07:00
Leonardo de Moura
7a323a0c7b feat: allow parser! and tparser! to set the parser precedence 2020-06-03 18:11:13 -07:00
Leonardo de Moura
7c76a19885 chore: fix includes 2020-05-22 14:17:25 -07:00
Leonardo de Moura
8bdca35282 chore: use #include <lean/runtime/...> for runtime .h files 2020-05-18 11:30:07 -07:00
Sebastian Ullrich
8f67db0101 refactor: never implicitly ignore monadic results
Also change `do e; f` to desugar to `e *> f` so that it is affected as well
2020-04-23 11:09:59 -07:00
Leonardo de Moura
6873400193 chore: remove silent | matchFailed support
Before this commit
```lean
pattern <- action
```
was being translated by the old frontend into
```lean
pattern <- action | matchFailed
```
This produced counterintuitive behavior, and performance problems when
tryin to synthesize `MonadFail` instances.
BTW, the new frontend does not implement this feature. I didn't even
remember the old frontend did this.
I will also remove the class `MonadFail` from stdlib.

cc @Kha @dselsam
2020-02-10 13:15:21 -08:00
Sebastian Ullrich
933ff6dc88 perf: short-circuit all antiquotation parsers 2020-02-06 08:12:08 -08:00
Sebastian Ullrich
1f2040727c feat: autogenerate antiquotations in parser! 2019-12-30 08:24:29 -08:00
Sebastian Ullrich
88a924b728 feat: support (almost) proper name resolution in quotations in the old frontend 2019-12-18 20:11:45 -08:00
Sebastian Ullrich
6a2dbad53f feat: match_syntax support in the old parser 2019-12-17 12:16:34 -08:00
Sebastian Ullrich
2310ec2413 chore: separate C++ calls for parsing & expansion 2019-12-17 12:16:34 -08:00
Leonardo de Moura
820f57880f chore: compilation warning 2019-12-11 09:53:28 -08:00
Sebastian Ullrich
52c97e7bee feat: integrate quotation terms into old parser 2019-12-10 22:45:35 +01:00
Leonardo de Moura
f88561ae68 feat: add trace! macro 2019-10-22 16:08:37 -07:00
Leonardo de Moura
4793cbfa9a feat: add #[elem1, elem2, ..] notation for creating arrays
@kha @dselsam: I added this notation because I am tired of writing
`[elem1, elem2, ...].toArray`. BTW, the new notation is based on the
one available in SML.
2019-10-07 15:36:44 -07:00
Leonardo de Moura
5801e0e65a fix: print module name instead of file name 2019-10-04 20:02:43 -07:00
Leonardo de Moura
261c0b9c24 feat(frontends/lean): add panic! macro
cc @dselsam
2019-09-30 17:16:19 -07:00
Leonardo de Moura
18d47a2b74 chore(frontends/lean): remove allow_field_notation = false setting
This setting was used for the explicit notation `@`.
We should not need it.
2019-07-17 19:09:15 -07:00
Leonardo de Moura
d03e00de99 chore(frontends/lean/builtin_exprs): remove obsolete notation from old parser 2019-07-17 19:09:15 -07:00
Leonardo de Moura
a3c0e2bb36 chore(frontends/lean/builtin_exprs): ensure old let notation is not accepted 2019-07-17 08:26:42 -07:00
Leonardo de Moura
7d062dd961 feat(frontends/lean): add new "empty/no match" syntax to old parser 2019-07-15 16:18:44 -07:00
Leonardo de Moura
8944767f6c chore(frontends/lean): Π ==> 2019-07-07 08:13:40 -07:00
Leonardo de Moura
0bee94886e feat(frontends/lean/builtin_exprs): , from ==> from, and cleanup suffices 2019-07-02 17:22:50 -07:00
Leonardo de Moura
7ba9a5012a chore(frontends/lean/builtin_exprs): make sure have-expression is consistent with let-expression 2019-07-02 16:46:51 -07:00
Leonardo de Moura
a02443d23d chore(frontends/lean): fun x, e ==> fun x => e 2019-07-02 13:22:11 -07:00
Leonardo de Moura
e29bf35d15 chore(frontends/lean/builtin_exprs): remove hard coded (::) notation 2019-07-02 11:01:05 -07:00
Leonardo de Moura
39221adcd6 chore(frontends/lean/builtin_exprs): remove assume notation 2019-07-02 10:40:07 -07:00
Leonardo de Moura
6841e47aa4 chore(frontends/lean/builtin_exprs): remove support for (<infix>) and (<infix> <expr>) notations
In Lean 4, we will support the more general

`a + ·` ==> `fun x, a + x`
`· + b` ==> `fun x, x + b`
`· + ·` ==> `fun x y, x + y`
`f · y` ==> `fun x, f a y`
`g · · b` ==> `fun x y, g x y b`
2019-07-02 08:06:06 -07:00
Leonardo de Moura
531ef5d700 feat(library/init/lean/parser): universe level parser and bug fixes 2019-06-30 09:02:06 -07:00
Leonardo de Moura
91e1d30cf8 feat(frontends/lean/builtin_exprs): use ; in do-notation 2019-06-27 18:00:43 -07:00
Leonardo de Moura
ab487ea4ac feat(frontends/lean): allow ; instead of in in let-decls 2019-06-27 17:12:03 -07:00
Leonardo de Moura
bc0c0ee9bc chore(tests): fix tests 2019-06-24 15:48:11 -07:00
Leonardo de Moura
da09ef4f66 feat(frontends/lean/builtin_exprs): minor improvement 2019-06-24 15:48:11 -07:00
Leonardo de Moura
24e3bff429 feat(frontends/lean): add simple parser! macro 2019-06-24 15:48:11 -07:00
Leonardo de Moura
4ab31275a4 chore(library/init, frontends/lean): remove foldl and foldr notation, and implement list notation in the old parser 2019-06-20 14:32:08 -07:00
Leonardo de Moura
9d9f546ad8 refactor(util/sexpr): move options and option_declarations to util 2019-05-16 14:37:24 -07:00
Leonardo de Moura
50207e2c5a chore(library/constants.txt): remove dead variables 2019-03-22 13:26:48 -07:00
Leonardo de Moura
930653f292 chore(library/init): Unit.star => Unit.unit
@kha Our stdlib is starting to match the names we used in our paper :)
2019-03-22 13:06:45 -07:00
Leonardo de Moura
870a0456c4 fix(frontends/lean/builtin_exprs): match name used at elaborator.lean 2019-03-21 15:06:46 -07:00
Leonardo de Moura
7ac847877f chore(library/init/Lean/Parser): more fixes 2019-03-21 15:06:44 -07:00
Leonardo de Moura
300aae08b3 chore(*): more fixes 2019-03-21 15:06:44 -07:00
Sebastian Ullrich
430fb81f69 fix(library/init/lean/parser/term,frontends/lean/builtin_exprs): @& should have higher rbp than -> 2019-03-07 14:35:25 +01:00
Leonardo de Moura
348ccf533c feat(library/compiler): borrowed annotations 2019-02-11 10:08:47 -08:00
Sebastian Ullrich
c8eaee74b4 feat(frontends/lean,library/init/lean/parser/combinators): add node_longest_choice! macro 2018-11-19 18:02:28 +01:00
Sebastian Ullrich
774d776133 feat(frontends/lean/builtin_exprs): pattern let with type 2018-11-19 14:15:25 +01:00
Sebastian Ullrich
da04491df1 fix(frontends/lean/builtin_exprs): trim view field names 2018-10-02 14:55:28 -07:00
Leonardo de Moura
a31f12d8cd chore(library/init/core): revert ite+thunks modification
We don't need it since we marked `ite` as `[macro_inline]`
2018-09-23 19:27:06 -07:00