Skip to content

component wit panics when an interface re-exports a type from outside an interface #2793

Open

Description

@jrandolf

wasm-tools component wit panics on this component, where the a:x/k instance re-exports a resource that the world imports directly:

(component
  (type $pkg (component
    (type $w (component
      (import "t" (type $t (sub resource)))
      (import "a:x/k" (instance (export "t" (type (eq $t)))))
    ))
    (export "root:component/root" (component (type $w)))
  ))
  (export "root" (type $pkg))
)
thread 'main' panicked at crates/wit-parser/src/resolve/mod.rs:1608:22:
internal error: entered unreachable code

Decoding gives interface k a use of the world's t, which WIT can't express, and Resolve::type_interface_dep doesn't expect a use of anything but an interface's type. Re-exporting a type from an unnamed instance, such as (import "foo" (instance (export "t" (type (sub resource))))), panics with "no entry found for key" at crates/wit-parser/src/decoding.rs:1611:58 instead.

Re-exporting an anonymous type that the component already used, such as a (list u32) that's also a parameter of a world function, hits the same unreachable!(), even though WIT can express it as type x = list<u32>.

Activity

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

    wit-componentIssues related to the wit-component crate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions