Skip to content

codegen for a bool return type when Hubpack is involved is invalid #66

@Aaron-Hartwig

Description

@Aaron-Hartwig

I have the following idol function:

        "rail_good": (
            args: {
                "name": "RailName",
            },
            reply: Simple("bool"),
            idempotent: true,
            encoding: Hubpack,
        ),

Which yields the following codegen:

pub fn rail_good(&self, name: RailName) -> bool {
        let (arg_name) = (name);
        #[allow(non_camel_case_types)]
        #[derive(serde::Serialize, hubpack::SerializedSize)]
        struct Sequencer_rail_good_ARGS {
            name: RailName,
        }
        const REPLY_SIZE: usize = { <bool as hubpack::SerializedSize>::MAX_SIZE };
        let mut reply = [0u8; REPLY_SIZE];
        let args = Sequencer_rail_good_ARGS {
            name: arg_name,
        };
        let mut argsbuf = [0; <Sequencer_rail_good_ARGS as hubpack::SerializedSize>::MAX_SIZE];
        let arglen = hubpack::serialize(&mut argsbuf, &args).unwrap_lite();
        loop {
            let task = self.current_id.get();
            let (rc, len) = sys_send(
                task,
                SequencerOperation::rail_good as u16,
                &argsbuf[..arglen],
                &mut reply,
                &[],
            );
            if let Some(g) = userlib::extract_new_generation(rc) {
                let _len = len;
                self.current_id.set(userlib::TaskId::for_index_and_gen(task.index(), g));
                continue;
            }
            let (v, _): (bool, _) = hubpack::deserialize(&reply[..len]).unwrap_lite();
            counters::count!(__SEQUENCER_CLIENT_COUNTERS, SequencerEvent::rail_good);
            return v != 0;
        }
    }

The code that is generated does not compile:

error[E0308]: mismatched types
   --> /hubris/target/thumbv7em-none-eabihf/release/build/drv-medusa-seq-api-d7233a5df42ce3bf/out/client_stub.rs:216:25
    |
216 |             return v != 0;
    |                    -    ^ expected `bool`, found integer
    |                    |
    |                    expected because this is `bool`

For more information about this error, try `rustc --explain E0308`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions