Stream: beginners

Topic: improving panics


view this post on Zulip jan kili (Dec 13 2021 at 15:52):

Can I improve the compile-time panic messages to be more helpful? I've tried setting RUST_BACKTRACE, but it doesn't seem to work.

[nix-shell:~/code/advent-of-code-2021]$ ./roc/target/release/roc build test.roc
thread 'main' panicked at 'Found StructValue(StructValue { struct_value: Value { name: "load_result", address: 0x600002c77980, is_const: false, is_null: false, is_undef: false, llvm_value: "  %load_result = load { { [3 x i64] }, i64 }, { { [3 x i64] }, i64 }* %result_value, align 8, !dbg !463", llvm_type: "{ { [3 x i64] }, i64 }" } }) but expected PointerValue variant', /Users/jan/.cargo/git/checkouts/inkwell-85610d8ccb0c28f9/e15d665/src/values/enums.rs:285:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
🔨 Rebuilding host...
[nix-shell:~/code/advent-of-code-2021]$ RUST_BACKTRACE=1

[nix-shell:~/code/advent-of-code-2021]$ ./roc/target/release/roc build test.roc
thread 'main' panicked at 'Found StructValue(StructValue { struct_value: Value { name: "load_result", address: 0x600003841640, is_const: false, is_null: false, is_undef: false, llvm_value: "  %load_result = load { { [3 x i64] }, i64 }, { { [3 x i64] }, i64 }* %result_value, align 8, !dbg !463", llvm_type: "{ { [3 x i64] }, i64 }" } }) but expected PointerValue variant', /Users/jan/.cargo/git/checkouts/inkwell-85610d8ccb0c28f9/e15d665/src/values/enums.rs:285:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
🔨 Rebuilding host...
[nix-shell:~/code/advent-of-code-2021]$

view this post on Zulip Folkert de Vries (Dec 13 2021 at 16:24):

oh I'd like to see the code for this

view this post on Zulip Folkert de Vries (Dec 13 2021 at 16:25):

is that the syntax for env variables in nix? it should show a backtrace

view this post on Zulip Anton (Dec 13 2021 at 16:29):

It's possible that you need to include RUST_BACKTRACE=1 in the nix.shell file under # Additional Env vars.
Then type exit in the nix shell and run nix-shell again.

view this post on Zulip Joshua Warner (Dec 13 2021 at 16:35):

@JanCVanB I think you need export RUST_BACKTRACE=1

view this post on Zulip jan kili (Dec 13 2021 at 16:44):

:face_palm: You're all right, bad env var. export RUST_BACKTRACE=1 works as intended.

view this post on Zulip Brendan Hansknecht (Dec 13 2021 at 16:45):

You should also just be able to put everything on the same line. That is what I normally do:
RUST_BACKTRACE=1 ./roc rest of command

view this post on Zulip Anton (Dec 13 2021 at 16:46):

Can you make an issue with the roc code included for the panic @JanCVanB ?

view this post on Zulip jan kili (Dec 13 2021 at 16:46):

Folkert de Vries said:

oh I'd like to see the code for this

This was trying to test File I/O via the example/cli/platform on the cli-file-io branch, but it seems to still be a work in progress.

view this post on Zulip jan kili (Dec 13 2021 at 16:47):

Given that context (and that I half-expected it to fail), do y'all still want me to submit an issue? @Anton

view this post on Zulip Anton (Dec 13 2021 at 16:51):

@Folkert de Vries ?

view this post on Zulip Folkert de Vries (Dec 13 2021 at 16:55):

Yes please


Last updated: Jul 06 2025 at 12:14 UTC