Commit graph

66 commits

Author SHA1 Message Date
Joshua Warner
f08a0012ea
Fix negative float and non-base-10 literal patterns 2025-01-16 21:16:53 -08:00
Joshua Warner
d43ad92789
Introduce proper type for TypeVar's, mark anything not a lowercase ident as malformed 2025-01-14 19:30:33 -08:00
Joshua Warner
586dc3486f
Fix formatting of negative numbers in pnc apply patterns 2025-01-11 11:05:33 -08:00
Joshua Warner
2e4e4bb957
Fix placement of comma after implements in pnc apply patterns 2025-01-11 11:05:33 -08:00
Joshua Warner
9f395e033d
Fix pnc apply pattern lift spaces 2025-01-09 21:06:08 -08:00
Anthony Bullard
9b9b6d39f3
Fix clippy 2025-01-08 15:37:03 -06:00
Anthony Bullard
898b3f55e5
Move PNC apply to separate Expr/Pattern variant 2025-01-08 14:47:49 -06:00
Anthony Bullard
a24fe430b4
Support '??' syntax for optional record fields 2025-01-04 14:26:20 -06:00
Anthony Bullard
3b0db07fa1
PNC for Patterns, stabilize formatting 2025-01-02 17:57:15 -06:00
Anthony Bullard
389cc940e0
Git rid of MigrationFlags constructor 2025-01-02 16:49:08 -06:00
Anthony Bullard
af39ce57fb
Parens and Commas application syntax 2025-01-02 16:49:08 -06:00
Joshua Warner
95d8fd471b
Refactor: Convert TypeAnnotation::Tuple to to_node, which required changing precedence information to flow up instead of down 2024-12-28 22:31:28 -05:00
Joshua Warner
35fa82cbef
Refactor: Convert TypeAnnotation::Record to to_node 2024-12-28 22:31:28 -05:00
Joshua Warner
d2e1c12b96
Refactor: introduce NodeInfo and needs_indent 2024-12-28 22:31:27 -05:00
Joshua Warner
dbbd097708
Always use to_node for TypeAnnotation::As 2024-12-28 22:31:25 -05:00
Joshua Warner
5b93e834f1
Refactor more things into TypeAnnotation::Nodify 2024-12-28 22:31:24 -05:00
Anthony Bullard
66529503ff
Fix snake case formatting 2024-12-17 05:40:42 -06:00
Joshua Warner
e068ae6b5a
Fix nested as 2024-12-16 18:23:40 -08:00
Joshua Warner
01dda78271
Add missing indent call 2024-12-15 18:33:58 -08:00
Joshua Warner
4a19926425
Relax implements handling in patterns 2024-12-15 18:33:58 -08:00
Joshua Warner
cc611533e0
Fix formatting of literals in closure args 2024-12-15 18:33:57 -08:00
Joshua Warner
0d182fbd28
Handle multiline string at the start of a pattern 2024-12-15 18:33:56 -08:00
Joshua Warner
c6d5983ff2
clippy fixes 2024-12-15 18:33:55 -08:00
Joshua Warner
20aee5c37b
Force type headers to format just like Pattern::Apply 2024-12-15 18:33:55 -08:00
Joshua Warner
cccb4abc30
Ensure formatted multiline record patterns work 2024-12-15 18:33:51 -08:00
Joshua Warner
8b7ac512f8
Generalize fmt rules around multiline strs in pats 2024-12-15 18:33:50 -08:00
Joshua Warner
db95ff54cf
Generalize multiline string handling in patterns 2024-12-15 18:33:48 -08:00
Joshua Warner
f193c778d5
clippy 2024-12-13 13:45:11 -08:00
Joshua Warner
f1d9667ea0
Fix multiline str pattern newline multiplication 2024-12-13 13:45:11 -08:00
Joshua Warner
e9a8588c3e
Refactor pattern apply 2024-12-13 13:45:10 -08:00
Joshua Warner
f5cd0568dd
Fix newlines after multiline apply func pattern (#7342) 2024-12-13 13:45:09 -08:00
Joshua Warner
8b3abafa08
Force newlines after multi-line tuple pattern elements 2024-12-13 13:45:09 -08:00
Joshua Warner
04612fb2cb
Fix as pattern formatting inside apply 2024-12-10 18:55:40 -08:00
Joshua Warner
dfcb7a0c3b
Ensure formatted multiline patterns can be parsed 2024-12-05 18:54:21 -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
Anton-4
7c1dffb777
minor improvements 2024-12-04 14:32:38 +01: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
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
4e19753189
fmt: Use format_with_options Parens for as pattern arguments 2024-09-02 12:02:01 -03:00
Joshua Warner
4f32f43048
Implement block / indent based parsing
... and enforce that defs can only occur in blocks (or, inside parenthesized expressions)
2024-07-27 13:34:16 -07:00
Luke Boswell
db4607125b
remove suffixed from Pattern 2024-04-28 08:47:08 +10: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
Anton-4
1efd7615f0
stylistic improvements 2024-03-13 20:27:23 +01:00
Eli Dowling
cc4453b301
remove alias 2024-03-12 06:42:37 +10:00
Eli Dowling
c89c8c3e95
fix formatter crash 2024-03-12 06:42:27 +10:00
Anton-4
9748e4a4dc
many clippy fixes 2023-04-24 16:21:46 +02:00