Skip to content

C: generating no-op functions #1438

@MendyBerger

Description

@MendyBerger

This might not be a huge issue, but probably worth pointing out anyway.

Given the following wit:

package my-namespace:my-package;

interface my-interface {
    type my-type = u32;
    record my-record {
        my-field: option<my-type>,
    }
}

world my-world {
    import my-interface;
}

With command:

wit-bindgen c wit --world my-world

Generates function:

void my_world_option_my_type_free(my_world_option_my_type_t *ptr) {
  if (ptr->is_some) {
  }
}

The if block seems extra if nothing is going to happen inside.

If I remove the option around my-type the free function is not being generated at all.

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