Commit graph

15396 commits

Author SHA1 Message Date
Sebastian Ullrich
d9246a8415 chore: adapt to new syntax syntax and introduce a few sepBy shorthands 2020-12-09 18:01:05 +01:00
Sebastian Ullrich
4dfa7e1187 feat: use actual separator in sepBy antiquotation scope 2020-12-09 17:48:05 +01:00
Sebastian Ullrich
7788e75c10 fix: use new sepBy syntax syntax 2020-12-09 17:36:29 +01:00
Sebastian Ullrich
fd1f74c421 feat: extend sepBy syntax syntax 2020-12-09 17:36:29 +01:00
Sebastian Ullrich
110b014752 chore: ParserCompiler: strip optParams 2020-12-09 17:36:26 +01:00
Sebastian Ullrich
f4267c9bf8 chore: revise Syntax.Traverser changes 2020-12-09 10:38:22 +01:00
Leonardo de Moura
f2339268b1 fix: adjust code to new match-compiler
In the new frontend,
```lean
@[macroInline] def or : Bool → Bool → Bool
  | true,  _ => true
  | false, b => b
```
is compiled as
```lean
def or (x y : Bool) : Bool :=
  or.match_1 _ x y (fun _ => true) (fun b => b)
```
Thus, the `[macroInline]` attribute does not guarantee that `y` is
evalutated only when `x` is `false`. The new definition does.

This issue was not exposed before because the compiler has an
optimization that float let-decls when they are used in a single
branch.

@Kha We have talked about removing `macroInline`, and defining
functions such as `or` as
```lean
@[inline] def or (x : Bool) (y : Unit -> Bool) : Bool :=
  match x with
  | true  => true
  | false => y ()
```
and define `x || y` as notation for `or x (fun _ => y)`.
I think this is the way to go for polymorphic operators such as `<|>`,
but I am not sure about `or`. New users will probably be puzzled by
it. In particular when they are writing proofs.
2020-12-08 13:46:00 -08:00
Leonardo de Moura
f14826a730 fix: incorrect context used at addDecForDeadParams 2020-12-08 12:38:33 -08:00
Leonardo de Moura
9a422ddc23 fix: Array.back on empty array 2020-12-08 12:21:01 -08:00
Leonardo de Moura
2ebee8d00c fix: missing addJP 2020-12-08 12:09:52 -08:00
Leonardo de Moura
702c258773 fix: index out of bounds
@Kha Please take a look at `Traverser` and check whether the
workaround is appropriate or not.
2020-12-08 11:44:10 -08:00
Leonardo de Moura
6a41d04827 fix: missing panics 2020-12-08 10:36:53 -08:00
Leonardo de Moura
ebf4a8877e chore: mark Neg Int as a default instance 2020-12-08 10:09:58 -08:00
Sebastian Ullrich
a20f7a2e8e chore: Elab.Quotation: avoid non-builtin syntax 2020-12-08 18:03:21 +01:00
Sebastian Ullrich
037144d3bd refactor: Delaborator.Builtins: eliminate remainder of manual syntax 2020-12-08 17:53:58 +01:00
Sebastian Ullrich
3c9619ed09 feat: Syntax.isNone: return true on missing 2020-12-08 17:33:51 +01:00
Sebastian Ullrich
e6493755e9 chore: stdlib: match_syntax ~> match 2020-12-08 17:32:02 +01:00
Sebastian Ullrich
290e1cf15f feat: syntax_match: check arity only for nullKind nodes 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
00e167b2f0 feat: match_syntax ~> match 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
6fac0c0b16 feat: support syntax patterns in do 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
93a9d79088 refactor: move around quotation helpers once more 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
32eeac88c8 fix: ensure matchAlts have same shape with and without optionalFirstBar 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
6fc03d0f29 feat: quotation scopes in match_syntax 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
c63b770a7c refactor: reduce dependencies on Lean.Elab.Quotation 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
b12be950bf feat: support complex antiquotations in antiquotation scopes 2020-12-08 17:13:32 +01:00
Leonardo de Moura
ae5aa51712 chore: add explicit discard 2020-12-08 06:18:18 -08:00
Leonardo de Moura
06ad52575a feat: force users to use discard when action result is not being bound and it is not PUnit
After this commit, we have to use an explicit `discard` in code such as
```
def g (x : Nat) : IO Nat := ...
def f (x : Nat) : IO Unit := do
  discard <| g x   -- type error without the `discard`
  IO.println x
```

Motivation: prevent users from making mistakes such as
```
def f (xs : Array Nat) : IO Unit := do
  xs.set! 0 1
  IO.println xs
```
when they meant to write
```
def f (xs : Array Nat) : IO Unit := do
  let xs := xs.set! 0 1
  IO.println xs
```
2020-12-08 06:14:48 -08:00
Leonardo de Moura
6dddcde25c chore: increase priority of defaultInstance for heterogeneous operators
@Kha The motivation is to allow users to define default instances such as
```lean
@[defaultInstance 1]
instance : OfScientific Real where
  ...
```
Then, numerals such as `1.2` and `3.4e10` will be `Real` by default instead of `Float`.
2020-12-07 16:58:34 -08:00
Leonardo de Moura
7e4b7e1400 fix: getFunBinderIds 2020-12-07 12:15:55 -08:00
Leonardo de Moura
cbf2b6c0db feat: change synthinstance threshold
Before this commit, the threshold was the amount of "fuel".
Now, it is the maximum number of instances used to solve a TC problem.
We have two thresholds
- `maxInstSize`: default 128
- `maxCoeSize`: default 16. It is similar to `maxInstSize`, but used for automatic coercions.

cc @Kha
2020-12-07 10:45:08 -08:00
Leonardo de Moura
6af3eac142 feat: add MonadStateCacheT based on StateT 2020-12-06 19:07:28 -08:00
Leonardo de Moura
906cb81319 feat: improve inferAppType
See comment at `Expr.instantiateRevRange`
2020-12-06 19:01:23 -08:00
Leonardo de Moura
91dec25a35 fix: bug at runST and runEST 2020-12-06 18:52:28 -08:00
Leonardo de Moura
265b7571b4 chore: change checkCache type 2020-12-06 16:24:51 -08:00
Leonardo de Moura
d25f520143 feat: elaborate #reduce command 2020-12-06 10:54:57 -08:00
Leonardo de Moura
1c0943ad82 feat: add #reduce command parser 2020-12-06 09:32:25 -08:00
Leonardo de Moura
f15986a25d fix: use levelMVarToParam at #check command 2020-12-06 09:28:41 -08:00
Leonardo de Moura
f33473a39e chore: use exists notation 2020-12-05 16:50:01 -08:00
Leonardo de Moura
1aaf7c0778 feat: add SimpleScopedEnvExtension
`ParserExtension` will probably be the only case where we need the
general case.
2020-12-05 16:38:35 -08:00
Leonardo de Moura
f0372f724c chore: remove unused attribute 2020-12-05 16:28:58 -08:00
Leonardo de Moura
44d0fe993a feat: ensure scoped instances cannot be used outside namespaces 2020-12-05 16:26:31 -08:00
Leonardo de Moura
533192c369 feat: implement instanceExtension using ScopedEnvExtension 2020-12-05 16:04:37 -08:00
Leonardo de Moura
fdc2c9f281 feat: process local instance ... and scoped instance ... commands 2020-12-05 15:46:25 -08:00
Leonardo de Moura
d27770ea0e chore: prepare to add scoped and local instances 2020-12-05 15:36:23 -08:00
Leonardo de Moura
1af03901da feat: scoped and local unification hints 2020-12-05 14:34:14 -08:00
Leonardo de Moura
1faed06dc1 feat: new attrKind syntax 2020-12-05 13:59:08 -08:00
Leonardo de Moura
f1f8c2482f feat: prepare to change attrKind parser
We want to add a proper node and kind.
2020-12-05 13:49:59 -08:00
Leonardo de Moura
32d5ef8b78 feat: scoped and local unification hints 2020-12-05 13:49:36 -08:00
Leonardo de Moura
d43a65aed0 feat: elaboarate local syntax, infix and notation commands 2020-12-05 08:05:40 -08:00
Leonardo de Moura
10102bf370 chore: remove "local" before attribute command
`local` is now part of the `Term.attrInstance` parser.
2020-12-05 07:47:28 -08:00