How does pattern matching on records work? I'm doing this
when Decode.fromBytes myJson Json.fromUtf8 is
Ok { message: { content } } -> process content
_ -> process "uh oh no content"
and I'm getting
── UNFINISHED WHEN ────────────────────────────────────────────────── main.roc ─
I was partway through parsing a when expression, but I got stuck here:
31│ Ok { message: { content } } ->
^
I was expecting to see a pattern next
Note: Here is an example of a valid when expression for reference.
when List.first plants is
Ok n ->
n
Err _ ->
200
Notice the indentation. All patterns are aligned, and each branch is
indented a bit more than the corresponding pattern. That is important!
that looks like a parsing bug - can you open an issue for it?
@JanCVanB Can you show the context of the when...is
? I remember having similar complaints when the when...is
did not have a separate line after the function ->
(presumably bad indentation).
Last updated: Jul 06 2025 at 12:14 UTC