Commit graph

406 commits

Author SHA1 Message Date
Joshua Warner
edcdd99f59
Record updates 2024-12-05 18:54:07 -08:00
Joshua Warner
b9862b47dc
Several fixes found in fuzzing 2024-12-05 18:54:03 -08:00
Joshua Warner
120e9be550
Move MigrationFlags from an argument on format* to a field on Buf
That has a few advantages:

* We avoid a bunch of extra parameter-passing "noise", since the vast majority of formatting code doesn't need to care about this setting beyond just passing it to nested format calls.
* It aligns really well with the "global" nature of this setting, and makes it impossible to have bugs where e.g. one callsite forgets to pass the correct value to it's children - which would lead to parts of the tree not being migrated. If this is truly a global setting on Buf, that simply can't happen.
2024-12-04 17:57:31 -08:00
Anthony Bullard
a2083cec30
Parsing support for snake_case identifiers
In this initial commit, I have done the following:

- Added unit tests to roc_parse's ident.rs file to cover at least the
  simplest Ident enum cases (Tag, OpaqueRef, and simple Access)
- Added '_' as a valid "rest" character in both uppercase and lowercase
  identifier parts
- Updated the test_syntax snapshots appropriately

There is still a lot left to do here. Such as:

- Do we want to allow multiple '_'s to parse successfully?
- Handle qualified access
- Handle accessor functions
- Handle record update functions
- Remove the UnderscoreInMiddle case from BadIdent
- Write unit tests for Malformed Idents

I am not a "Rustacean" by any means, but have been through the Book in
years past.  Any feedback on the way I wrote the tests or any other part
of the implementation would be very appreciated.
2024-12-03 20:50:47 -06:00
Joshua Warner
f7a5f06e5b
Fix a bunch of bugs found in fuzzing 2024-12-01 12:40:19 -08:00
Joshua Warner
5cd38c969f
Fix a couple minor parsing bugs 2024-12-01 12:40:17 -08:00
Joshua Warner
d4301e86a3
Improve parsing of negative + not'd exprs 2024-12-01 12:40:16 -08:00
Joshua Warner
61d885039d
Improve normalization to handle cases found in fuzzing 2024-12-01 12:40:14 -08:00
Joshua Warner
912db1b76b
Fix round-trip parse->fmt->parse for dbg stmts with more than one arg 2024-12-01 12:40:13 -08:00
Joshua Warner
cfd83ffcdf
Add some currently-passing tests 2024-12-01 12:40:08 -08:00
Joshua Warner
085c5e2fe7
Fix nasty perf bug in parsing types 2024-12-01 12:39:47 -08:00
Anton-4
74d137cad4
Revert "Merge pull request #7267 from joshuawarner32/fuzzing-bugs-2"
This reverts commit 364249a29d, reversing
changes made to 0e550a7f68.
2024-11-30 18:43:16 +01:00
Joshua Warner
ed62bcc15a
Fix a bunch of parser/formatter bugs found in fuzzing
Notably:
* Unified how parens are formatted between (1) when we have a ParensAround, and (2) when we've decided an Apply needs to have parens
* Made unary minus require the be indented to the same level as any other expression continuation. (it used to accidentally have rules meant for binary operators applied)
* Don't apply extra indent to the backpassing continuation in the case that the call does itself require indentation
* Make `try@foo` correctly parse as `try @foo`, so that formatting doesn't change the tree when it adds that space
* Detect more cases where we need to outdent trailing e.g. {} blocks in applies
* Approximately a bagillion other things, 90% of which I added tests for, and none of which affected the formatting of examples or builtins
2024-11-29 16:25:59 -08:00
Agus Zubiaga
1dc9dd0a90
Merge branch 'main' into specialize-exprs 2024-11-27 11:35:14 -03:00
Joshua Warner
b4fdb0a4c2
Make dbg parse strictly as an Apply
This is important in order to fix some formatting bugs found in fuzzing
2024-11-24 14:15:29 -08:00
Agus Zubiaga
5d6c47b25f
Update test_syntax snapshot after new Slice debug impl 2024-11-23 11:05:09 -03:00
Joshua Warner
9ead801536
Remove expect-fx syntax and handling
This was never fully hooked up in platforms, and the plan is to replace the need for this with doing purity-inference on normal `expect` statements.

On the other hand, fuzzing is finding some bugs caused by having a hyphenated keyword, so this is a great time to go ahead and remove it!
2024-11-17 20:25:37 -08:00
Joshua Warner
550113df67
Fix some bugs found via fuzzing
* Keywords need to still be recognized if they're followed by ',' as well as a bunch of other operator characters. Notably missing from this list is '-', since that would mess up expect-fx currently.
* Smattering of niche cases of formatting bugs (either non-idempotency, leading to different code, or leading to unparsable code)
* One missing indent call in fmt_collection leading to a panic
2024-11-15 21:33:44 -08:00
Luke Boswell
09bd145845
update snapshot for newline_in_packages syntax test 2024-11-11 20:04:12 +11:00
Luke Boswell
8a566dc339
WIP 2024-11-11 10:22:58 +11:00
Luke Boswell
c00db6da37
Merge remote-tracking branch 'remote/main' into rebuild-platform 2024-11-04 13:57:51 +11:00
Sam Mohr
de124ecc3e
Finish adding tests 2024-11-02 21:58:25 -07:00
Sam Mohr
012387b1ff
Fix tests broken by recent internal syntax changes 2024-10-25 04:23:48 -07:00
Sam Mohr
294f0c0d1f
Merge branch 'main' into return-keyword 2024-10-24 23:01:10 -07:00
Luke Boswell
926014518f
Merge remote-tracking branch 'remote/main' into rebuild-platform 2024-10-24 10:21:08 +11:00
Richard Feldman
21dd2ad85d
Update parsing snapshot tests 2024-10-21 23:19:25 -04:00
Sam Mohr
7518a2c5ab
Address PR comments, add syntax tests 2024-10-21 03:06:43 -07:00
Luke Boswell
0271f2eeb2
Merge pull request #7151 from hrishisd/deprecate-old-str-interpolation
Remove deprecated string interpolation syntax #7148
2024-10-09 11:21:18 +11:00
Luke Boswell
de9491eb7f
Merge remote-tracking branch 'remote/main' into rebuild-platform 2024-10-09 09:57:27 +11:00
Luke Boswell
e3afeaa7ff
WIP Merge remote-tracking branch 'remote/main' into rebuild-platform 2024-10-09 09:21:46 +11:00
hrishisd
cb98c45e88
Remove deprecated string interpolation syntax 2024-10-08 16:31:22 -04:00
Brendan Hansknecht
7ae5242c1b
fix syntax snapshot tests 2024-10-07 21:16:30 -07:00
Sam Mohr
2da08be8ef
Remove old record builder syntax 2024-09-21 04:44:44 -07:00
snobee
6edee521cb
add tests 2024-09-06 19:34:11 -07:00
snobee
e82dd43465
Merge remote-tracking branch 'upstream/MAIN' into early-return-if-else 2024-09-06 17:11:28 -07:00
snobee
139f6ae82c
update tests for new Expr::If struct 2024-09-06 16:28:14 -07:00
Elias Mulhall
19931ecd43
Support passing values into dbg with the pipe operator
In order to desugar `dbg` in a pipeline we need to allow a bare `dbg`
node in desugaring and only report it as an error if the bare node
survives to the next step of canonicalization. This means we move the
error code out of `desugar_expr` and into `canonicalize_expr`. This is
much simpler to do now that these functions use the same `env` struct,
since previously we would have had to pass down extra args to
`canonicalize_expr`. Sharing the `env` struct means that we also don't
have to worry about calculating `line_info` more than once.
2024-09-05 20:13:54 -04:00
Luke Boswell
bb57c4a600
remove unneded basic-cli reference in test_reporting 2024-09-04 21:50:15 +10:00
Agus Zubiaga
2469a3aa2d
Merge pull request #7050 from roc-lang/arg-patterns-as 2024-09-02 14:02:17 -03:00
Agus Zubiaga
2486ce0e48
fmt: Add parens around as patterns in arguments 2024-09-02 11:54:34 -03:00
Anton-4
02cf61f985
Merge pull request #7038 from mulias/expr-dbg
Support `dbg` in expressions
2024-09-02 13:30:32 +02:00
Anton-4
e7a44430fd
update to basic cli 15 2024-08-31 14:30:07 +02:00
Elias Mulhall
56c5b790a7 Refactor dbg expression parsing to work more like function application
Instead of parsing dbg with an expression block, parse the dbg keyword
with no additional arguments. This way the parser treats dbg just like a
variable in function application. We desugar by pattern matching on
`Apply(Dbg, args, called_via)` nodes. This changes the output of syntax
tests since the initial AST is different, but does not change the output
of can or mono.

Add two new errors for dbg in expression position with either no args or
too many args. This is similar to the error behavior of `crash`.

Continue to parse dbg statements with an expression block, as before.
2024-08-29 15:36:48 -04:00
Anton-4
7938e4bdc8
basic-cli 0.15, test fixes 2024-08-28 18:39:15 +02:00
Elias Mulhall
335265e15c Parse dbg in expression position
Add dbg parsing logic everywhere we parse normal expressions. Add
special case to statement parsing to handle a series of statements
ending in a `dbg` in expression position.

Rename existing `dbg_help` function to `dbg_stmt_help`, similarly rename
syntax snapshot test files to specify which ones are for dbg statements.
2024-08-28 11:53:44 -04:00
Elias Mulhall
43d932df3b Update parser AST to support dbg as both a statment and expression
Make `Expr::Dbg` node specific to dbg expressions, add `Expr::DbgStmt`
for dbg statements. Debug expressions don't have a continuation branch.
Support formatting both kinds of `Dbg` nodes.
2024-08-28 11:53:44 -04:00
Luke Boswell
10241b3f98
Merge remote-tracking branch 'remote/main' into builtin-task 2024-08-24 09:53:08 +10:00
Anton-4
44b8abdead
update to basic-cli 0.14 2024-08-23 15:50:05 +02:00
Sam Mohr
12df3a04de
Merge attempt 2024-08-19 23:34:05 -07:00
Joshua Warner
6b6968632f
Merge branch 'main' into format-invisible-chars 2024-08-17 10:22:40 -07:00