Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure in print_tyid when using a list of lists in both param/return form and with a type definition #551

Closed
philpax opened this issue Mar 29, 2023 · 1 comment · Fixed by #552

Comments

@philpax
Copy link
Contributor

philpax commented Mar 29, 2023

I was testing out #547 with our bindings, and encountered this assert:
https://github.com/bytecodealliance/wit-bindgen/blob/main/crates/rust-lib/src/lib.rs#L245

This is the minimal repro:

default world bindings {
    import component: self.component
}

interface component {
    type value = list<tuple<>>
    type entity = list<tuple<u32, value>>

    add-components: func(entity: u64, data: entity)
    query-eval: func(q: u64) -> list<tuple<u64, list<value>>>
}

Note that the type entity is necessary; substituting its definition into add-components allows for generation to pass.

This is the resulting callstack:

% RUST_BACKTRACE=1 wit-bindgen rust wit -w main
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"'a"`,
 right: `"'_"`', wit-bindgen-f98ccff846621481/58c130a/crates/rust-lib/src/lib.rs:245:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: wit_bindgen_rust_lib::RustGenerator::print_tyid
   5: wit_bindgen_rust_lib::RustGenerator::print_ty
   6: wit_bindgen_rust_lib::RustGenerator::print_tyid
   7: wit_bindgen_rust_lib::RustGenerator::print_ty
   8: wit_bindgen_rust_lib::RustGenerator::print_rust_slice
   9: wit_bindgen_rust_lib::RustGenerator::print_type_list
  10: <wit_bindgen_rust::RustWasm as wit_bindgen_core::WorldGenerator>::import_interface
  11: wit_bindgen_core::WorldGenerator::generate
  12: wit_bindgen::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

(with the latest wit-bindgen-cli installed through cargo install --git https://github.com/bytecodealliance/wit-bindgen.git wit-bindgen-cli)

alexcrichton added a commit to alexcrichton/witx-bindgen that referenced this issue Mar 29, 2023
I forgot a context where the assertion would trip, so implement the code
necessary to avoid the need for the assertion.

Closes bytecodealliance#551
@alexcrichton
Copy link
Member

Thanks! I think #552 should fix this

alexcrichton added a commit that referenced this issue Mar 29, 2023
I forgot a context where the assertion would trip, so implement the code
necessary to avoid the need for the assertion.

Closes #551
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants