Stream: wit-bindgen

Topic: Compatibility of enum/variant


view this post on Zulip anb (Nov 19 2025 at 17:56):

Hi, I wonder if there's any docs about adding/removing members from enum/variant break binary compatibility? And if so, what's the best/safe way to change an existing enum?

view this post on Zulip Lann Martin (Nov 19 2025 at 18:23):

I don't think there is any kind of variant subtyping currently implemented in the component model, so any changes to variant cases would be backward-incompatible. The only "safe" ways to migrate would be to create a new variant that is only used by new functions or by updating the package version to indicate the backward-incompatibility.

view this post on Zulip anb (Nov 19 2025 at 18:47):

Thanks Lann, how about enum? Is it backed by integers? Any way to safely change it without breaking anything?

view this post on Zulip Lann Martin (Nov 19 2025 at 18:55):

Same for enums and all other value types. The ABI does indeed use integers but components have self-describing interfaces that include most of what is specified in WIT; see the spec here: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Binary.md#type-definitions

Repository for design and specification of the Component Model - WebAssembly/component-model

view this post on Zulip Lann Martin (Nov 19 2025 at 18:57):

In the specific case of enum you can see that the binary type information includes <label> strings.

view this post on Zulip anb (Nov 19 2025 at 19:27):

That feels like a pain :-/

view this post on Zulip Lann Martin (Nov 19 2025 at 21:06):

There was a rough outline of subtyping prior to the 0.2 release but it was removed. You can see some discussion of why here: #wasi > `@since` gates on variant and enum members? @ 💬


Last updated: Dec 06 2025 at 07:03 UTC