Skip to content

rust: bug with merge structurally equal types #1543

@chenyan2002

Description

@chenyan2002

When merge structurally equal types is enabled, I get panic at path_to_interface function. Basically, the owner of TypeId from get_representative_type is not in self.r#gen.interface_names.

I can work around some of these cases by calling compute_module_path when the lookup fails. This happens when WIT import and export the same interface, but it doesn't always panic.

In some other cases, the interfaceId points to an unused interface, which is not present in bindings.rs. The case I see so far is for primitive types,

package a;
type Duration = u32;

package b;
type Counter = u32;

With equal types, we get type Counter = Duration, but since Duration is not used, it's not in the bindgen code. This particular case can be fixed by disallowing aliasing for primitive types. But I don't know if there are cases other than primitives.

I don't have a minimal repo yet, but think this may be related to the nominal id patch. I tried to bump wasm-tools to 0.245.1, but still the same problem. When can an interface live outside of self.r#gen.interface_names or we need to maintain dependency differently when merging equal types?

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