Commit graph

69 commits

Author SHA1 Message Date
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
Agus Zubiaga
7a7650c11d
Parse lowercase idents ending in ! 2024-11-07 18:54:14 -03:00
Agus Zubiaga
2cce5ad023
Allow unsuffixed statements in parser
Moves the "STATEMENT AFTER EXPRESSION" error from the parser to canonicalization.
We'll later use this to allow this case in effectful functions.
2024-11-07 18:54:14 -03:00
Agus Zubiaga
ef4eeb5c1a
Parse effectful arrow in function annotations 2024-11-07 18:54:11 -03:00
Sam Mohr
de124ecc3e
Finish adding tests 2024-11-02 21:58:25 -07:00
Sam Mohr
7518a2c5ab
Address PR comments, add syntax tests 2024-10-21 03:06:43 -07:00
hrishisd
cb98c45e88
Remove deprecated string interpolation syntax 2024-10-08 16:31:22 -04:00
snobee
6edee521cb
add tests 2024-09-06 19:34:11 -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
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
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
Sam Mohr
b1a972ab21
Implement &foo record updater syntax sugar 2024-08-16 01:41:59 -07:00
Sam Mohr
3bc5c1dc12
Combine ! and ? into single TrySuffix AST node 2024-08-14 22:14:08 -07:00
Sam Mohr
00bc699642
Add syntax tests for record builder 2024-08-06 22:49:35 -07:00
Joshua Warner
4e8b36adbf
Fix auto-fixing of deprecated interpolated strings 2024-07-29 17:37:55 -07: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
Agus Zubiaga
e5a09b5de6
Parse module params in import 2024-05-09 07:42:07 -03:00
Agus Zubiaga
08825a9e90
Add module with optional param syntax test 2024-05-09 07:27:58 -03:00
Agus Zubiaga
370013b960
Format module header with params 2024-05-09 07:27:58 -03:00
Agus Zubiaga
760ffaf68f
Report module params parse error 2024-05-09 07:27:58 -03:00
Agus Zubiaga
5b1a3c8f03
Parse params in module header
module {echo, read} -> [menu]

Formatter isn't implemented yet.
2024-05-09 07:27:43 -03:00
Agus Zubiaga
22716cea45
Format ingested file with optional annotation 2024-05-05 16:56:49 -03:00
Agus Zubiaga
8dedd9f03c
New app header syntax
Implements the new app header syntax as discussed in Zulip [1].

    app [main] {
	cli: platform "../platform/main.roc",
	json: "../json/main.roc"
    }

Old headers still parse and are automatically upgraded to the new
syntax by the formatter.

[1] 418444862
2024-05-01 10:49:01 -03:00
Agus Zubiaga
057a18573a
New module header
Implements the new `module` header syntax as described in "module and package changes" [1]:

```
module [Request, Response, req]
```

The old syntax should still work fine, and is automatically upgraded to the new one
when running `roc format`.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit
2024-05-01 10:39:12 -03:00
Agus Zubiaga
a8a829aadd
Merge branch 'main' into inline-imports 2024-04-28 00:11:29 -03:00
Luke Boswell
2fe03e6c91
remove suffixed from Expr::Var 2024-04-28 08:47:08 +10:00
Agus Zubiaga
4476277a56
Merge branch 'main' into inline-imports 2024-04-22 17:45:25 -03:00
Luke Boswell
6844df6c37
fix parsing lists in tag patterns 2024-04-21 13:27:50 +10:00
Agus Zubiaga
d5a38a26db
Merge branch 'main' into inline-imports 2024-04-20 12:01:11 -03:00
Luke Boswell
0a3b9c34b3
add suffixed:u8 to Expr::Var 2024-04-14 13:45:00 +10:00
Luke Boswell
56d91ce74c
support multiline suffixed statements 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
Jonathan Schear
ab4a5343a0
Update tests 2024-03-24 14:31:34 -04:00
Luke Boswell
e2557067c8
add nested snapshot for suffixed expr 2024-03-15 14:40:09 +11:00
Luke Boswell
8bbbd768ec
add snapshot test for suffixed expr 2024-03-15 14:39:21 +11:00
Agus Zubiaga
11e0202eb9
Parse inline imports and ingested files at the expression level
```
numbers =
    import "numbers.json" as numbersJson : Str
    import json.Decode exposing [decode, list, int]

    numbersJson
    |> decode (list int)
    |> Result.withDefault []
```
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
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
Richard Feldman
ff2704056e
Fix some tests 2024-01-07 00:00:37 -05:00
Richard Feldman
163bde0c41
Update tests to use $(...) interpolation 2024-01-06 15:06:30 -05:00
ptaszor3
6a6d5cebc0
resolved issue 6188 and added some tests 2023-12-10 19:57:49 +01:00
Agus Zubiaga
ebc3aab91f
Allow where to be used as an identifier (except in type vars) 2023-09-30 01:48:10 -03:00
Folkert
ef39bad7c6
auto clippy fixes 2023-07-10 18:27:08 +02:00
Joshua Warner
654248ad47
Allow spaces before and after the colon in the packages header section
Fixes #4902
2023-07-03 15:46:50 -07:00