Stream: beginners

Topic: mono/src/ir Option::unwrap() on None


view this post on Zulip Zenna (Dec 05 2024 at 09:57):

hey y'all running into a compiler panic when trying to work with dicts. This is the error I'm getting

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

and this is the code causing it

partOne = \(rules, updates) ->
    rulesDict = List.walk rules (Dict.empty {}) \dict, (k, r) ->
        Dict.update dict k \res -> when res is
            Err Missing -> Ok [r]
            Ok rs -> Ok (List.append rs r)
    rulesDict

was hoping someone could point me to a workaround

view this post on Zulip Luke Boswell (Dec 05 2024 at 10:03):

Does it help if you add a type annotation for rulesDict or the function?

view this post on Zulip Luke Boswell (Dec 05 2024 at 10:04):

I suspect the issue here might be that the compiler is having trouble inferring the type for the Dict

view this post on Zulip Zenna (Dec 05 2024 at 10:12):

it does! thank you :)

view this post on Zulip Luke Boswell (Dec 05 2024 at 10:13):

Ideally the compiler shouldn't crash, and at least give a nice error message.

view this post on Zulip Luke Boswell (Dec 05 2024 at 10:16):

I've had a brief look at it, but mono is a bit of black magic to me and I'm not sure how we might thread an error back through the compiler from there.

view this post on Zulip Sam Mohr (Dec 05 2024 at 10:21):

Two things about mono errors:


Last updated: Jul 06 2025 at 12:14 UTC