Skip to content

Comments

avoid generating duplicate stream and future constructors#206

Merged
dicej merged 1 commit intobytecodealliance:mainfrom
dicej:avoid-duplicate-future-stream-ctors
Feb 24, 2026
Merged

avoid generating duplicate stream and future constructors#206
dicej merged 1 commit intobytecodealliance:mainfrom
dicej:avoid-duplicate-future-stream-ctors

Conversation

@dicej
Copy link
Collaborator

@dicej dicej commented Feb 23, 2026

Previously, we used the payload type to avoid generating duplicates, but that doesn't work reliably because wit-parser does not necessarily deduplicate types involving aliases, such as the following example:

interface types {
  variant foo {
    bar,
    baz
  }
}

interface use-types-a {
  use types.{foo};

  test: func() -> future<result<foo>>;
}

interface use-types-b {
  use types.{foo};

  test: func() -> future<result<foo>>;
}

When targetting a world which imports and/or exports both use-types-a and use-types-b, we'll end up with distinct type IDs for result<foo>.

This commit switches to using wit-bindgen-core to determine the "canonical" type of the payload and then use that as the deduplication key. This unblocks using wasi:cli@0.3.0-rc-2026-02-09, which has a similar pattern to the above WIT example.

Note that this is awkward to test given our current test infra, but #205 will cover it once it's merged.

@dicej
Copy link
Collaborator Author

dicej commented Feb 23, 2026

Actually, I just realized wit_bindgen_core supports a better way to do this; going to use that instead.

Previously, we used the payload type to avoid generating duplicates, but that
doesn't work reliably because `wit-parser` does not necessarily deduplicate
types involving aliases, such as the following example:

```
interface types {
  variant foo {
    bar,
    baz
  }
}

interface use-types-a {
  use types.{foo};

  test: func() -> future<result<foo>>;
}

interface use-types-b {
  use types.{foo};

  test: func() -> future<result<foo>>;
}
```

When targetting a world which imports and/or exports both `use-types-a` and
`use-types-b`, we'll end up with distinct type IDs for `result<foo>`.

This commit switches to using `wit-bindgen-core` to determine the "canonical"
type of the payload and then use that as the deduplication key.  This unblocks
using `wasi:cli@0.3.0-rc-2026-02-09`, which has a similar pattern to the above
WIT example.

Note that this is awkward to test given our current test infra, but bytecodealliance#205 will
cover it once it's merged.
@dicej dicej force-pushed the avoid-duplicate-future-stream-ctors branch from b701558 to 79f3ce3 Compare February 23, 2026 23:25
@dicej dicej merged commit 89af297 into bytecodealliance:main Feb 24, 2026
4 checks passed
@dicej dicej deleted the avoid-duplicate-future-stream-ctors branch February 24, 2026 00:14
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 this pull request may close these issues.

1 participant