Skip to content

Panic when processing type aliases to owned resource handles #1412

@kavoc-brown

Description

@kavoc-brown

Summary

wit-bindgen panics when processing WIT files that contain type aliases to resource handles (e.g., type my-handle = own<my-resource>).

Environment

  • wit-bindgen version: 0.47.0
  • Affected component: wit-bindgen-core
  • OS: Ubuntu 22.04, x86-64

Steps to Reproduce

  1. Create a minimal WIT file

    Save the following as test.wit:

    package poc:demo;
    
    interface db {
      resource database {
        constructor();
        query: func(sql: string) -> string;
      }
    
      // Type alias to owned resource handle
      type db-handle = own<database>;
    
      connect: func() -> db-handle;
    }
    
    world test-world {
      export db;
    }
  2. Run wit-bindgen

    wit-bindgen rust --out-dir /tmp/test test.wit
  3. Observe the panic

    thread 'main' panicked at /home/runner/work/wit-bindgen/wit-bindgen/crates/core/src/lib.rs:183:39:
    handle types do not require definition
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    gen-rustRelated to bindings for Rust-compiled-to-WebAssembly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions