Commit graph

25 commits

Author SHA1 Message Date
Folkert
394495d307 Revert "update size asserts"
This reverts commit 9973d4b8d2.
2023-04-21 13:22:23 +02:00
Folkert
4cd8f0a056 clippy --fix fixes 2023-04-21 12:05:51 +02:00
Joshua Warner
b5f284cd78
Fix several fmt+parse bugs found by fuzzing 2023-02-19 12:37:33 -08:00
Joshua Warner
2541a09273
Fix formatting of initial newlines in collections
Fixes #5015
2023-02-17 09:08:50 -08:00
Joshua Warner
3fee0d3e8f
Fix a bunch of bugs in parsing/formatting found by fuzzing 2023-02-07 20:25:56 -08:00
Joshua Warner
d876abb04b
Fix formatting of backpassing in a nested def with no newline
Fixes #4338
2023-01-16 09:31:08 -08:00
Joshua Warner
0b8e68f70d
Fix approximately a bajillion fmt and parsing bugs
(discovered by fuzzing)

There's more to come, but this seems like a good batch for now.
2023-01-13 18:20:44 -08:00
Joshua Warner
a046428ce6
Add fuzzing for the formatter and fix bugs
This commit adds fuzzing for the (expr) formatter, with the same invariants that we use for fmt tests:
  * We start with text, which we parse
  * We format the AST, which must succeed
  * We parse back the AST and make sure it's identical igoring whitespace+comments
  * We format the new AST and assert it's equal to the first formatted version ("idempotency")

Interestingly, while a lot of bugs this found were in the formatter, it also found some parsing bugs.

It then fixes a bunch of bugs that fell out:
* Some small oversights in RemoveSpaces
* Make sure `_a` doesn't parse as an inferred type (`_`) followed by an identifier (parsing bug!)
* Call `extract_spaces` on a parsed expr before matching on it, lest it be Expr::SpaceBefore - when parsing aliases
* A few cases where the formatter generated invalid/different code
* Numerous formatting bugs that caused the formatting to not be idempotent

The last point there is worth talking further about. There were several cases where the old code was trying to enforce strong
opinions about how to insert newlines in function types and defs. In both of those cases, it looked like the goals of
(1) idempotency, (2) giving the user some say in the output, and (3) these strong opinions - were often in conflict.

For these cases, I erred on the side of following the user's existing choices about where to put newlines.

We can go back and re-add this strong opinionation later - but this seemed the right approach for now.
2022-12-17 09:52:09 -08:00
Richard Feldman
49f8768271
Parse and format dbg 2022-11-22 21:08:26 -05:00
Joshua Warner
1efd7260de
Add fmt test to make sure formatting works for all parser test cases 2022-11-14 08:20:35 -05:00
Ayaz Hafiz
f6c21cc933
Correctly format abilities with comments 2022-10-04 10:03:51 -05:00
Richard Feldman
8e6abc8079
Clean up some formatter logic 2022-09-11 20:18:40 -04:00
Folkert
bcbc8b4d50
basic canonicalization 2022-08-09 13:59:24 +02:00
Richard Feldman
a3e441c086
Fix top-level expect formatting bugs 2022-08-04 23:14:19 -04:00
Richard Feldman
0d0cebc40d
Reproduce expect formatting bugs 2022-08-04 23:14:16 -04:00
Folkert
7597d11b59
parse the region of the preceding comment for an expect 2022-07-21 10:42:57 -04:00
Richard Feldman
f575807834
Merge remote-tracking branch 'origin/trunk' into outdent-infix 2022-07-16 16:08:36 -04:00
Ayaz Hafiz
be9944a7e1
Improve indent of has-abilities clauses 2022-07-15 11:59:03 -04:00
Richard Feldman
fa877e4184
Revert "Special-case records, lists, functions in def fmt"
This reverts commit c0b4ceea9b1d817c923eb82fa3ff7a36db90199f.
2022-07-13 22:32:42 -04:00
Richard Feldman
2be68189b4
Special-case records, lists, functions in def fmt 2022-07-13 22:32:42 -04:00
Richard Feldman
8178f22ce4
Always put a newline after a binop def body 2022-07-13 22:32:41 -04:00
Folkert
3dee90ced8
remove parse::ast::Def 2022-07-10 01:10:37 +02:00
Richard Feldman
5f0e3c72c5
Fix unstable formatting on opaque unions 2022-07-08 15:29:08 -04:00
Richard Feldman
01434c8e28
Don't over-indent type alias defs 2022-07-06 13:55:45 -04:00
Anton-4
eee85fa45d
moved all crates into seperate folder + related path fixes 2022-07-01 17:37:43 +02:00
Renamed from compiler/fmt/src/def.rs (Browse further)