Commit graph

56 commits

Author SHA1 Message Date
Agustin Zubiaga
4cd2c957ca
Format multiline reecord builder fields nicely 2023-05-17 12:48:37 -03:00
Agustin Zubiaga
5edcb31f32
Outdentable record builders 2023-05-17 12:21:39 -03:00
Agustin Zubiaga
d1feb00170
Track spaces between : and <- in record builders 2023-05-17 11:49:06 -03:00
Agustin Zubiaga
731cd4257d
Record Builder colon arrow syntax 2023-05-16 22:44:55 -03:00
Agustin Zubiaga
d2a57112fd Unapplied record builder error 2023-05-08 20:16:38 -03:00
Agustin Zubiaga
6670fbb1ab Multiple record builder error 2023-05-08 19:26:47 -03:00
Agustin Zubiaga
c2e50a22b6 Record Builder formatting 2023-05-07 15:51:08 -03: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
Brendan Hansknecht
56ed985cc9
pass through correct path and type for ingested file 2023-04-09 14:03:32 -07:00
Brendan Hansknecht
f4411afbbc
get basic wiring of a value through the compiler 2023-04-09 14:03:31 -07:00
Joshua Warner
b5f284cd78
Fix several fmt+parse bugs found by fuzzing 2023-02-19 12:37:33 -08:00
Ayaz
9340a67e87
Merge pull request #4993 from joshuawarner32/tuple-gen-tuple-backend-experiment
Implement mono / code generation for tuples
2023-02-08 10:42:51 -05: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
5a6be05ead
implement mono / lowering for tuples 2023-02-07 18:54:50 -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
94070e8ba6
Improve parsing of scalar literals
* Unify parsing of string literals and scalar literals, to (e.g.) ensure escapes are handled uniformly. Notably, this makes unicode escapes valid in scalar literals.
* Add a variety of custom error messages about specific failure cases of parsing string/scalar literals. For example, if we're expecting a string (e.g. a package name in the header) and the user tried using single quotes, give a clear message about that.
* Fix formatting of unicode escapes (they previously used {}, now correctly use () to match roc strings)
2023-01-07 15:12:52 -08:00
Joshua Warner
07ebc81cba
Be more lenient with indentation in record parsing
... and extract a shared helper with collection_trailing_sep_e, thereby resolving some inconsistencies with normal collection parsing.

... and delete some dead code while I'm at it
2023-01-02 18:53:15 -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
Nathan Freestone
83f4cdfaeb
fix for format behavior for multi-line strings 2022-12-11 18:38:47 -07:00
Ayaz Hafiz
aab509c5c1
Make sure to escape formatting of char literals
Closes #4682
2022-12-05 14:09:28 -06:00
Ayaz Hafiz
1011ce9fba
Format crash 2022-11-24 14:46:49 -06:00
Folkert
e44a8a9eed
print all the relevant info 2022-11-23 22:58:58 +01: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
Joshua Warner
f4ce4bf983
Implement parsing for tuple accessor functions (.1, .2, etc)
Step 2 of N toward implementing #4465
2022-11-12 09:56:29 -05:00
Joshua Warner
1753c9cf5b
Implement initial tuple syntax 2022-11-08 18:04:46 -05:00
Folkert
66a1ba00eb
1.65 clippy fixes 2022-11-03 16:20:37 +01:00
Ayaz Hafiz
bbb2083dd6
Correctly format nested pipeline operators
Closes #4151
2022-10-03 14:18:17 -05:00
Ayaz Hafiz
3883867b5c
Properly format characters with escape sequences
Ran into this just now
2022-10-02 17:10:34 -05:00
raleng
1c8bc7d969
Fix formatting block string containing quotes
Single-line block strings are parsed as PlainLines. When the string
contains quotes, this leads to invalid formatted strings. This commit
special cases strings containing quotes the same as strings containing
newlines and formats them to multiple lines using triple-quotes.
2022-08-26 11:36:54 +02:00
raleng
4991adb05b
Fix multiline string formatting
This change adds the proper indentation when formatting multiline
strings to not end up with invalid code. This also make sure that
multiline strings are always formatted using multiple lines, regardless
of the string literal itself contains a newline.
2022-08-26 11:13:37 +02:00
raleng
1b2952bc70
Fix invalid multiline string output in REPL
If a PlainLine string contains a newline character, the REPL will print
the string using a triple-quoted block string.
2022-08-23 11:26:48 +02:00
Richard Feldman
862b58b8f9
Fix expect formatting in expressions 2022-08-04 23:14:19 -04:00
Richard Feldman
47dd3743e7
Revert "Don't keep comments right after the ->"
This reverts commit 326337ae00624e7f326ce92aa473a48283bcbf98.
2022-07-13 23:16:08 -04:00
Richard Feldman
18be76ea43
Don't keep comments right after the ->
(at least not when the branch is a multiline expr!)
2022-07-13 23:16:08 -04:00
Richard Feldman
d3f5117d76
Revert "Simplify some branch formatting logic"
This reverts commit 597055c1e580363f8645d3f9cc74134bd1e07bbe.
2022-07-13 23:16:08 -04:00
Richard Feldman
b51c8b0ba4
Simplify some branch formatting logic 2022-07-13 23:16:08 -04:00
Richard Feldman
9e19baef59
Don't indent next expr after multiline binop 2022-07-13 22:05:04 -04:00
Richard Feldman
28e0a9e382
Don't indent multiple patterns 2022-07-13 21:50:30 -04:00
Richard Feldman
f066ee12dc
Don't indent multiline infix operators 2022-07-13 21:40:28 -04:00
Richard Feldman
b08d6a0446
Fix edge case with comments and branches 2022-07-11 13:14:35 -04:00
Richard Feldman
4530d9ebd3
Format multiline branches with newlines before 2022-07-11 13:12:34 -04:00
Richard Feldman
42a110dc6b
clippy 2022-07-06 16:51:25 -04:00
Richard Feldman
82c81a7039
Allow comments after the -> in a when 2022-07-06 16:48:28 -04:00
Richard Feldman
15932d7d47
Fix comments in when branches 2022-07-06 16:42:54 -04:00
Richard Feldman
18edf5f0d6
Fix comments in when conditionals 2022-07-06 16:42:53 -04:00
Richard Feldman
f01d6a55f7
Fix multiline_binop_conditional_with_comments 2022-07-06 16:42:53 -04:00
Richard Feldman
da8a1fb81f
Fix starts_with_newline logic 2022-07-06 16:42:53 -04:00
Richard Feldman
824de8bcc9
Rename with_inline_comment to has_line_comment_before 2022-07-06 16:42:53 -04:00
Richard Feldman
7eba683355
s/bin_op/binop/g
This is the term we use elsewhere in the compiler
2022-07-06 16:42:53 -04:00