Skip to content

Component bindgen fails when a parameter or field is named b #1940

Open

Description

@ludfjig

host_bindgen! output doesn't compile when a WIT parameter or record field is named b:

package a:b;
world w { export f: func(a: u32, b: string) -> u32; }
error[E0608]: cannot index into a value of type `usize`
    let b_field = &r#b[b_cursor..];

The generated decoder stores byte counts in a local named b, for example at hl.rs#L64. The WIT name b becomes the identifier r#b, which is the same name, so the counter shadows the value. The same pattern appears in several other places in hl.rs.

The counters need names that can't collide with WIT names, for example derived from id as other temporaries are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions