roc-json icon indicating copy to clipboard operation
roc-json copied to clipboard

Segfault when parsing a List (Str, Dec)

Open ageron opened this issue 5 months ago • 1 comments

I'm trying to add the rest-api exercise to the roc track on exercism. It involves parsing a JSON object containing a Dict, but unfortunately this is blocked by #33 . I thought I could work around this by replacing the Dict Str Dec with a List (Str, Dec). Unfortunately, I'm now running into a segfault.

Here's a code example to reproduce the issue (I'm using roc nightly pre-release, built from commit 54cd967 on Fri Sep 6 09:02:04 UTC 2024):

app [main] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br",
    json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.10.2/FH4N0Sw-JSFXJfG3j54VEDPtXOoN-6I9v_IA8S18IGk.tar.br",
}

import json.Json

main =
    Task.ok {}

ListOfTuples: List (Str, Dec)

expect
    jsonStr = "[[\"Alice\", 1.1], [\"Bob\", 2.2], [\"Charles\", 3.3]]"
    result : Result ListOfTuples _
    result = jsonStr |> Str.toUtf8 |> Decode.fromBytes Json.utf8
    result == Ok [("Alice", 1.1), ("Bob", 2.2), ("Charles", 3.3)]

ageron avatar Sep 07 '24 00:09 ageron