roc icon indicating copy to clipboard operation
roc copied to clipboard

panic on json encode with optional Frac *

Open adomurad opened this issue 1 year ago • 2 comments

When trying to run this example I get a panic from the compiler:

app [main] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.11.0/SY4WWMhWQ9NvQgvIthcv15AUeA7rAIJHAHgiaSHGhdY.tar.br",
    json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.10.0/KbIfTNbxShRX1A1FgXei1SpO5Jn8sgP6HP6PXbi-xyA.tar.br",
}

import pf.Task
import json.Json

main =
    pdf = printPdf {}
    Task.ok {}

# printPdf : { page ? F32 } -> List U8
printPdf = \{ page ? 21.4 } ->
    obj = {
        page,
    }
    Encode.toBytes obj Json.utf8

Result:

thread '<unnamed>' panicked at crates/compiler/mono/src/ir.rs:6143:56:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

When I uncomment the type annotation # printPdf : { page ? F32 } -> List U8 (Frac * becomes F32) then I can run the example on Linux using --linker=legacy .

I have tried older compiler versions, older basic-cli platforms, and older json packages - all the same.

The example works with ints (e.g. I32, Num *) and with Str.

adomurad avatar Jul 02 '24 12:07 adomurad