Skip to content

Instances passed to nested components keep the caller's type #14853

Closed

Description

@jrandolf

When an outer component instantiates an inner one, the instance passed for an inner import isn't re-typed to the inner component's declared import type. If the inner component re-exports that import, the re-export takes its type and attributes from the outer argument:

(component
  (core module $m (func (export "f") (result i32) i32.const 7))
  (core instance $i (instantiate $m))
  (func $f (result u32) (canon lift (core func $i "f")))
  (instance $n)
  (instance $arg (export "n" (implements "p:q/r") (instance $n)) (export "extra" (func $f)))
  (component $inner
    (import "x" (instance $x (export "n" (implements "x:y/z") (instance))))
    (export "y" (instance $x)))
  (instance $inst (instantiate $inner (with "x" (instance $arg))))
  (export "out" (instance $inst "y"))
)

Wasmtime reports out/n as implementing p:q/r (the inner component declared x:y/z), and out has an extra export that the inner component never declared and that the host can look up. wasmparser's types for the same component have n implementing x:y/z and no extra.

The argument seems to be pushed as-is in inline.rs (frame.push_item(arg.clone())), and record_export then takes nested attributes from the outer type.

Activity

  1. added a commit that references this issue on Oct 20, 2026
    483f9f4
  2. added a commit that references this issue on Oct 20, 2026
    d23440d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions