Skip to content

Export type ascription is ignored, so exports it hides stay reachable #14852

Open

Description

@jrandolf

Wasmtime ignores the type ascription on component exports. For example:

(component
  (core module $m
    (func (export "f") (result i32) i32.const 1)
    (func (export "g") (result i32) i32.const 2))
  (core instance $i (instantiate $m))
  (func $f (result u32) (canon lift (core func $i "f")))
  (func $g (result u32) (canon lift (core func $i "g")))
  (instance $inst (export "f" (func $f)) (export "g" (func $g)))
  (export "hidden" (instance $inst) (instance (export "f" (func (result u32)))))
)

The ascription hides g, but component_type() still lists g under hidden, and the host can look it up with Instance::get_export_index(Some(&hidden), "g") and call it (it returns 2). Attributes that come from the ascription, such as (implements "..") or (external-id "..") on a nested export, are lost as well, and the same item can report different attributes depending on which path it's exported through.

It looks like translate.rs records (item, name) for exports and drops export.ty, and the root export types are then built from the definition rather than the ascribed type. Guests aren't affected; this is about what the embedder API exposes.

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

    wasm-proposal:component-modelIssues related to the WebAssembly Component Model proposal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions