Commit Graph

95 Commits

Author SHA1 Message Date
Ayaz Hafiz
759f8d86af
Fix lifetime errors due to interner
In the llvm backend, there are the lifetimes `'a` (lifetime of the
global arena) and `'ctx` (lifetime of constructed LLVM values). `'a`
lives longer than `'ctx`, but the compiler didn't enforce this until
the layout interner was introduced, for some reason. We have to make
sure that containers of lifetime `'a` have no `'ctx` references.
2022-12-29 11:38:34 -06: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
e3687935a3
Merge remote-tracking branch 'origin/main' into refactor-platform-info 2022-12-09 22:21:25 -05:00
Richard Feldman
63e9f5da8c
Go back to old opt_main_for_host 2022-12-09 22:18:52 -05:00
Folkert
a72556b927
refactor entry point 2022-12-09 15:10:25 +01:00
Richard Feldman
8b463686bc
Propagate multiple entrypoints to alias analysis 2022-12-08 15:31:42 -05:00
Richard Feldman
49f8768271
Parse and format dbg 2022-11-22 21:08:26 -05:00
Joshua Warner
2d9aba2242
Refactor parser methods to not return State as part of ParseError
As previously discovered with #4464, it's easy to accidentally mis-use the State value returned on the Err path.

There were mixed assumptions about what that State represents: (1) the State where the error occurred, or (2) the State at the beginning of the thing we were just parsing.

I fixed this up to always mean (2) - at which point we don't actually need to return the State at all - so it's impossible for further discrepency to creep in.

I also took the liberty to refactor a few more methods to be purely combinator-based, rather than calling `parse` directly.
2022-11-18 19:52:23 -05:00
Folkert
662bf1de99
more workspace dependencies 2022-11-13 16:10:02 +01:00
Folkert
2c23a106f2
make inkwell a workspace dependency 2022-11-13 15:00:48 +01:00
Anton-4
a6a2b59a79
Merge branch 'main' of github.com:lukewilliamboswell/roc into rust-docs 2022-11-08 15:57:24 +01:00
Luke Boswell
cec67721e6
merge upstream/main 2022-11-06 09:27:46 +11:00
Joshua Warner
5d5b71a083
Refactor several parse methods to use more combinators 2022-11-05 09:44:08 -04:00
Richard Feldman
c2004d9779
Fix incomplete when detection in repl 2022-11-05 01:22:26 -04:00
Richard Feldman
0657c38bb4
Merge branch 'repl' into repl-warnings
Signed-off-by: Richard Feldman <oss@rtfeldman.com>
2022-11-03 20:05:18 -07:00
Luke Boswell
f3bdb5f321
updating rust package documentation 2022-11-03 20:00:06 +11:00
Richard Feldman
e2451c7f22
Drop the gray lines from the repl 2022-11-01 22:05:47 -04:00
Richard Feldman
1499ec5def
Drop termline dependency 2022-11-01 21:42:08 -04:00
Richard Feldman
19ffa61f8f
Add a gray line after each repl output 2022-11-01 15:57:22 -04:00
Richard Feldman
fb799d1d24
clippy 2022-11-01 01:27:15 -04:00
Richard Feldman
afa88bfd41
Don't shadow unnecessarily 2022-11-01 01:24:58 -04:00
Richard Feldman
560c984d30
Fix error filtering region math 2022-11-01 01:20:52 -04:00
Richard Feldman
167e8a40de
Print (filtered) warnings in the repl again 2022-11-01 00:25:11 -04:00
Richard Feldman
9854dceec8
Filter out warnings and errors for past defs 2022-11-01 00:24:49 -04:00
Richard Feldman
220c362671
Merge remote-tracking branch 'origin/main' into repl 2022-10-31 20:49:28 -04:00
Joshua Warner
07be8ec000
Refactor Parser trait to pass min_indent
This removes the need to explicitly pass thru min_indent when using the parser combinators.

My ultimate goal here is to evolve the current parser closer toward a purely combinator-based parser,
at which point we can more easily transition smoothly to a formal(ish) grammar, or expand the meanings of combinators
to include things like:
* Incremental (re)parsing
* Unified parsing and formatting code
* Better error recovery
* Using the main parser directly for syntax highlighting
2022-10-31 13:31:47 -07:00
Richard Feldman
50ebffad5a
Fix Windows Readline error 2022-10-31 07:28:24 -04:00
Richard Feldman
9265d6480d
clippy 2022-10-31 07:12:57 -04:00
Richard Feldman
212090769f
Fix repl handling of invalid layouts 2022-10-31 06:57:52 -04:00
Richard Feldman
d6853519d8
Expand repl TIPS 2022-10-31 06:53:27 -04:00
Richard Feldman
cb7ee6a43a
Have repl error eagerly on confirmed syntax errors 2022-10-31 06:40:38 -04:00
Richard Feldman
e6bd2a5f30
Handle syntax errors in repl 2022-10-31 06:22:35 -04:00
Richard Feldman
2b89f53e76
Right-align var_name if terminal under 80 chars 2022-10-31 06:14:43 -04:00
Richard Feldman
8b4e864a90
Support opaques, aliases, and abilities in repl 2022-10-30 15:03:59 -04:00
Richard Feldman
23974dc753
Drop unused lifetime annotation 2022-10-30 14:42:00 -04:00
Richard Feldman
d7fd72c905
Fix eval-ing functions in repl 2022-10-30 14:41:57 -04:00
Richard Feldman
eebf973f11
repl treats whens as incomplete until blank line 2022-10-30 13:48:06 -04:00
Richard Feldman
0c8f6a0a72
Fix annotated defs in repl 2022-10-30 13:34:38 -04:00
Richard Feldman
daa87093ca
Don't drop defs that would be shadowed 2022-10-30 12:42:20 -04:00
Richard Feldman
a574dff481
Don't print repl output if there were errors 2022-10-30 05:57:21 -04:00
Richard Feldman
062d532fa4
Fix most repl tests 2022-10-30 05:47:05 -04:00
Richard Feldman
08cf8e727f
have the repl eval named defs 2022-10-30 03:58:44 -04:00
Richard Feldman
4d8a3ba3d7
Don't persist defs if they have errors 2022-10-30 03:42:30 -04:00
Richard Feldman
0190787f7b
Revert "send panics to the repl more gracefully"
Now doesn't seem like the right time to do a change this invasive.

This reverts commit a36ddbf6cb.
2022-10-30 03:12:53 -04:00
Richard Feldman
a36ddbf6cb
WIP send panics to the repl more gracefully 2022-10-30 03:12:41 -04:00
Richard Feldman
45e800c328
Don't print warnings in the REPL 2022-10-30 03:12:27 -04:00
Richard Feldman
875a2181a0
Right-align var_name output in repl (at 80 cols) 2022-10-30 02:47:26 -04:00
Richard Feldman
aa1dcee709
Hackily filter out UNUSED warnings in repl 2022-10-30 02:18:52 -04:00
Richard Feldman
b7d3c77b76
Have the repl eval anyway if there are errors 2022-10-27 18:47:32 -04:00
Richard Feldman
f841cdb2c0
Persist defs 2022-10-27 18:47:32 -04:00