wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

Panic when processing type aliases to owned resource handles

Open kavoc-brown opened this issue 1 month ago • 0 comments

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
    

kavoc-brown avatar Nov 09 '25 15:11 kavoc-brown