Hi,
New to Roc, I'm trying to decode one of two possible json values, but I'm running in to this problem:
thread '<unnamed>' panicked at 'Ability specialization is unknown - code generation cannot proceed!: DeriveError(Underivable)', crates/compiler/mono/src/ir.rs:6146:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The interesting part of the code is this:
JsonDecoded : List [Empty Str, Occupied { occupied : Str }]
decoded : DecodeResult JsonDecoded
decoded =
"[\"empty\", {\"occupied\": \"user\"}]"
|> Str.toUtf8
|> fromBytesPartial (jsonWithOptions { fieldNameMapping: KebabCase })
I'm using lukewilliamboswell/roc-json 0.4.0, the full code can be found here https://gist.github.com/souze/5cbb51e1df1563bd588e5b3254ade59b
I've also tried with
JsonDecoded : List [Empty, Occupied Str]
and
JsonDecoded : List [Empty, Occupied {occupied: Str}]
But with the same result.
Decoding tags is currently not implemented in the compiler. You can see the implementation of the Decode
ability in crates/compiler/builtins/roc/Decode.roc
. That will most likely be what is causing this issue.
I think @Isaac Van Doren is currently working on implementing these, here is an ongoing discussion on the topic
I see, thanks a lot! I'll keep an eye out, in the meantime, maybe I can hand-parse this specific case :)
Last updated: Jul 05 2025 at 12:14 UTC