Stream: platform development

Topic: Providing Tag with payload


view this post on Zulip Oskar Hahn (Jan 03 2025 at 20:35):

I am trying to provide a function to the host, that expects as its argument a tag with a payload. For example

main_for_host : [TagWithoutPlayload, TagWithPayload U64] -> U64
main_for_host = \tag ->
    when tag is
        TagWithoutPlayload -> 0
        TagWithPayload payload -> payload

When I try to build this with roc build --lib main.roc, I get the error:

thread 'main' panicked at /home/ossi/.cargo/git/checkouts/inkwell-946411d814d2c9f8/89e06af/src/values/enums.rs:325:13:
Found StructValue(StructValue { struct_value: Value { name: "", address: 0x5b8843bbdf78, is_const: false, is_null: false, is_undef: false, llvm_value: "{ [1 x i64], i8 } %1", llvm_type: "{ [1 x i64], i8 }" } }) but expected PointerValue variant

stack backtrace:

It works, if the function only has one Tag (for example [TagWithPayload U64]. It also works, if both tags do not have a payload (for example [TagWithoutPlayload, TagWithPayload]).

Am I doing something forbidden or is this a bug?

view this post on Zulip Brendan Hansknecht (Jan 03 2025 at 20:58):

Definitely a bug

view this post on Zulip Brendan Hansknecht (Jan 03 2025 at 20:58):

Looks like a call conv issue if I had to guess

view this post on Zulip Brendan Hansknecht (Jan 03 2025 at 21:00):

Yeah, I think it has a struct and is trying to use it as a pointer when passing to/from the host


Last updated: Jul 06 2025 at 12:14 UTC