Skip to content

Tolerate duplicate imports when creating components #2063

@erikrose

Description

@erikrose

Multiple imports of the same name are in-spec for core-wasm modules but not allowed for components. Currently, attempting to componentize a module with non-uniquely named imports yields…

% wasm-tools component new main-with-dupe-imports.wasm -o component-with-dupes.wasm --adapt wasi_snapshot_preview1.wasm
error: failed to encode a component from module

Caused by:
    0: failed to decode world from module
    1: module was not valid
    2: module has duplicate import for `wasi_snapshot_preview1::fd_write`

We should pick a unique import of each name and ignore the rest when componentizing. Since inter-component linking is done solely by name, multiple same-named imports have no way of being distinguished in order to be satisfied individually—even if they had unique types, for example—and so nothing is lost by ignoring them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions