Commit graph

14231 commits

Author SHA1 Message Date
Sebastian Ullrich
519eda2459 feat: formatter: interpret checkWsBefore as soft space 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
95007171a8 feat: formatter: group+indent binders and structure instance fields 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
97a2198fe0 feat: change default indent width from 4 to 2 spaces 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
ec3682ce15 feat: formatter: automatically group+indent syntax categories 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
ac6c2b7a8e feat: formatter: interpret space after token as soft space 2020-09-18 13:15:40 -07:00
Leonardo de Moura
5a24cb5ef7 feat: add hygienicIntro option
@Kha `hygienicIntro` is true by default. `hygienicIntro == false` is
the Lean3 behavior. If we find `hygienicIntro` too inconvenient in
practice, we set the default to false.
2020-09-18 13:02:38 -07:00
Leonardo de Moura
12aabcb731 feat: add introNP and intro1P
Versions of `introN` and `intro1` that preserve the binder name.
They are used to implement the idiom: "revert", do something, re-"intro"-tuce
Before this commit `introNP mvarId n` was `intro1 mvarId n [] false`.
2020-09-18 12:35:25 -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
22dc784c3e chore: cleanup 2020-09-18 11:37:51 -07:00
Leonardo de Moura
0e8f8117a1 refactor: simpler mechanism for never backtracking traces
We do backtrack messages but not traces.

cc @Kha
2020-09-18 10:31:42 -07:00
Leonardo de Moura
a28679358e refactor: remove MonadError 2020-09-18 09:58:13 -07:00
Leonardo de Moura
0d295560c3 feat: add replaceLocalDecl
It preserves the location of the local declaration.
@Kha This tactic is going to be used to fix another hygiene related bug in
Lean3 :)
Here is small repro for the problem.
```
example (m n k : ℕ) (h : 0 + n = m) (h : k = m) : ...  :=
begin
  -- Here `h : k = m` is accessible.
  rw [nat.zero_add] at *
  -- `h : k = m` is not accessible anymore, and it is a name for
  -- the simplified `h : n = m` which was inaccessible before.
end
```
2020-09-17 19:27:48 -07:00
Leonardo de Moura
36bfe7b266 feat: add assertAfter tactic 2020-09-17 19:25:53 -07:00
Leonardo de Moura
7b6d06df0d fix: remove bad instances
They are unnecessary, and were producing a very big search space in a
few examples.
2020-09-17 17:31:09 -07:00
Leonardo de Moura
9c8f57f322 fix: preserve info messages from candidates that failed to be elaborated
@Kha Not sure whether we should have an option for supressing this
information or not.
We need this information for diagnosing problems. For example, I was trying to
understand why the elaborator was looping. I suspected it was the
TC module, but I was not getting any trace messages since the symbol
was overloaded, and the case that did not work was the expensive one :(
2020-09-17 17:08:14 -07:00
Leonardo de Moura
59bf4defc6 fix: default value 2020-09-17 15:58:29 -07:00
Leonardo de Moura
3dbe2076b9 refactor: Target&LocalDecl => Replace 2020-09-17 13:59:22 -07:00
Leonardo de Moura
4ea8db2722 chore: cleanup 2020-09-17 13:50:40 -07:00
Leonardo de Moura
8142548237 fix: missing toggleInsideQuot
cc @Kha
2020-09-17 13:23:52 -07:00
Leonardo de Moura
d1c3ab3797 feat: many1Unbox and nodeSepBy1Unbox parser combinators
@Kha I removed the dummy parenthesizer/formatter for `withResultOf`,
and add proper ones for `many1Unbox` and `nodeSepBy1Unbox`.
2020-09-17 13:17:46 -07:00
Leonardo de Moura
3a6d579bbb feat: expand rewriteSeq macro 2020-09-17 12:32:22 -07:00
Leonardo de Moura
cf85080e7a feat: proper support for nullKind at evalTactic
@Kha When we write command macros, we can easily expand a command
into multiple ones by using `mkNullNode [cmd_1, ... cmd_n]`. Before
this commit, a tactic macro that expands into a sequence of tactics
had to produce `mkNullNode [tac_1, "; ", ..., "; ", tac_n]`.
I forgot the ";" a few times, and it produces very counterintuitive
behavior. This commit is the last step for fixing this issue.
The previous commits add the `withResultOf p f` combinator that allows
us to implement variants of the `unboxSingleton` trick. Now,
```
`(tactic| t)
```
Produces just `t` as before, but
```
`(tactic| t_1; t_2)
```
produces
```
Syntax.node `Tactic.seq [[t_1, "; ", t_2]]
```
instead of
```
Syntax.node `null [t_1, "; ", t_2]
```
2020-09-17 12:20:57 -07:00
Leonardo de Moura
2dafdec000 feat: use withResultOf combinator instead of unboxSingleton parameter 2020-09-17 12:12:12 -07:00
Leonardo de Moura
4265348bed feat: add withResultOf parser combinator and unboxSingleton 2020-09-17 12:03:16 -07:00
Leonardo de Moura
56f8103e66 chore: improve error message for rw [] 2020-09-17 10:55:51 -07:00
Leonardo de Moura
e9d65dd2de chore: improve sanitizeNames superscripts
cc @Kha
2020-09-17 08:57:54 -07:00
Leonardo de Moura
71f91cca23 chore: make sure isClass? return none when argument contains type errors
This is particularly useful for the delaborator when trying to pretty
print code that contains type errors.
2020-09-17 08:24:06 -07:00
Leonardo de Moura
57bed74871 chore: add Rewrite.lean 2020-09-17 08:15:58 -07:00
Leonardo de Moura
f4aabaecae refactor: move Lean.quote to LeanInit
cc @Kha
2020-09-17 08:15:58 -07:00
Leonardo de Moura
9d1f2b644f chore: rwRuleSeq ; => , 2020-09-17 08:15:58 -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
Sebastian Ullrich
98453c468b feat: formatter: don't escape inaccessible names 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
9b6370bdbe feat: formatter: escaping compound identifiers 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
0b9e46eee5 chore: universe-+ spacing 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
fad4660135 feat: pretty print space between binders 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
131f30f7a9 feat: pretty print tuples 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
27d936ffa5 feat: pretty print structure instances 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
532ea76a0a fix: elaborator: do not panic on structure instance without expected type 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
be85024724 fix: erase macro scopes on structure instance field names 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
310fc986c1 chore: MetaHasEval TermElabM: print messages 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
f4e6635f2b chore: getMessageStringEx: show exception 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
6a91fb1613 fix: delaborating projections 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
c4761974b7 fix: runParserCategory: ensure EOI 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
02a6b4d126 chore: remove obsolete code 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
f09a83d38a fix: delaborating projections 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
bacc77efa1 feat: delaborate builtin operators 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
fd423bada7 fix: pretty print loose bound variables 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
753b598232 fix: delaborator: ignore mdata by default 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
c4812f6e7a feat: pretty print let 2020-09-17 08:12:28 -07:00