Commit graph

46 commits

Author SHA1 Message Date
Agus Zubiaga
3217e5a3f0
Allow dots in import module names
We found some issues with the private submodules part of the proposal [1],
and we decided to keep module directories for now.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit#heading=h.x84bh32l37em
2024-04-20 12:33:02 -03:00
Agus Zubiaga
d5a38a26db
Merge branch 'main' into inline-imports 2024-04-20 12:01:11 -03:00
Luke Boswell
3c3e523b45
add suffixed to Identifer and QualifiedIdentifier 2024-04-14 13:45:00 +10:00
Luke Boswell
42fdcb7ff1
Make unit assignment optional for suffixed defs 2024-04-14 13:44:59 +10:00
Agus Zubiaga
08e6b79dca
fmt: Simplify ModuleImport is_multiline 2024-01-20 08:39:33 -03:00
Agus Zubiaga
2d93f0c3f1
Extract ModuleImport/IngestedFileImport into structs for reuse 2024-01-20 08:35:50 -03:00
Agus Zubiaga
4d6e641864
Parse and format inline ingested file imports 2024-01-20 08:35:50 -03:00
Agus Zubiaga
42e755677c
Simply import parsing and formatting by using header::KeywordItem 2024-01-20 08:35:50 -03:00
Agus Zubiaga
65ce811587
Parse and format import package shorthand
The original proposal [1] suggested dropping the package shorthand,
but we later decided to keep it [2] to improve UX.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit?usp=sharing
[2] 385104011
2024-01-20 08:35:50 -03:00
Agus Zubiaga
c56091ee3e
Module Params' proposal import syntax
I previously implemented the syntax in "Proposal: Module and Package Changes" [1]:

```
import [map, map2] from JsonDecode as JD
```

However, we decided [2] to use the one that appears in "Proposal: Module Params" [3]:

```
import JsonDecode as JD exposing [map, map2]
```

The new implementation also now supports comments and newlines between all the tokens.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit
[2] 405410612
[3] https://docs.google.com/document/d/110MwQi7Dpo1Y69ECFXyyvDWzF4OYv1BLojIm08qDTvg/edit
2024-01-20 08:35:50 -03:00
Agus Zubiaga
5cd084b73c
Parse and format inline import with exposed names 2024-01-20 08:35:50 -03:00
Agus Zubiaga
76d799ea13
Parse and format aliases in import defs 2024-01-20 08:35:50 -03:00
Agus Zubiaga
933fde77a0
Parse and format top-level import defs with no alias or exposed members 2024-01-20 08:35:50 -03:00
ptaszor3
58b73ae257
Fixed some formatting 2023-12-10 19:58:23 +01:00
ptaszor3
7162fbddd3
Fixed the multiline dbg formatting 2023-12-10 19:58:09 +01:00
Richard Feldman
2da41be29f
Merge remote-tracking branch 'origin/main' into abilities-syntax 2023-08-10 20:36:01 -04:00
Kiryl Dziamura
1bb3c3d1dd
Make has have 4 identation spaces 2023-07-04 11:24:40 +02:00
Bryce Miller
cb08225bf0
| -> where 2023-06-05 20:19:00 -04:00
Bryce Miller
e514d0cb83
Define and use IMPLEMENTS const in roc_parse::keyword 2023-05-29 07:21:27 -04:00
Bryce Miller
d2503bb9f2
has -> implements 2023-05-26 22:59:29 -04:00
Bryce Miller
46cb45f717
loc_has -> loc_implements 2023-05-20 19:24:08 -04:00
Anton-4
9748e4a4dc
many clippy fixes 2023-04-24 16:21:46 +02:00
Anton-4
e784baccce
rust update, nix update, clippy fixes 2023-04-22 14:51:01 +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)