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.
This commit is contained in:
Elias Mulhall 2024-09-03 22:27:45 -04:00
parent b515bfa77e
commit 19931ecd43
No known key found for this signature in database
GPG key ID: 8D1F3C219EAB45F2
10 changed files with 200 additions and 28 deletions

View file

@ -0,0 +1,16 @@
SpaceAfter(
BinOps(
[
(
@0-1 Num(
"1",
),
@2-4 Pizza,
),
],
@5-8 Dbg,
),
[
Newline,
],
)

View file

@ -0,0 +1 @@
1 |> dbg

View file

@ -442,6 +442,7 @@ mod test_snapshots {
pass/pattern_as_spaces.expr,
pass/pattern_with_space_in_parens.expr, // https://github.com/roc-lang/roc/issues/929
pass/pizza_bang.moduledefs,
pass/pizza_dbg.expr,
pass/plus_if.expr,
pass/plus_when.expr,
pass/pos_inf_float.expr,