Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

- [#306](https://github.com/bytecodealliance/go-modules/issues/306): do not emit incompatible version feature gates when serializing WIT. For example, if a world with version `0.1.0` *includes* a world from another package with a `@since(version = 0.2.0)` feature gate, then strip that feature gate when serializing to WIT if the version is greater than the world’s package version.
- [#350](https://github.com/bytecodealliance/go-modules/issues/350): correctly align `record` size to the highest alignment of its fields, per [specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#element-size).

- [#352](https://github.com/bytecodealliance/go-modules/issues/352): do not use `tuple` types as data shape for `variant` or `result` types, as they may contain a `bool` or not be packed.

## [v0.6.2] — 2025-03-16

Expand Down
9 changes: 9 additions & 0 deletions testdata/issues/issue352.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package issues:issue352;

world w {
import i;
}

interface i {
type a = result<tuple<bool, bool, bool>, s16>;
}
64 changes: 64 additions & 0 deletions testdata/issues/issue352.wit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"worlds": [
{
"name": "w",
"imports": {
"interface-0": {
"interface": {
"id": 0
}
}
},
"exports": {},
"package": 0
}
],
"interfaces": [
{
"name": "i",
"types": {
"a": 1
},
"functions": {},
"package": 0
}
],
"types": [
{
"name": null,
"kind": {
"tuple": {
"types": [
"bool",
"bool",
"bool"
]
}
},
"owner": null
},
{
"name": "a",
"kind": {
"result": {
"ok": 0,
"err": "s16"
}
},
"owner": {
"interface": 0
}
}
],
"packages": [
{
"name": "issues:issue352",
"interfaces": {
"i": 0
},
"worlds": {
"w": 0
}
}
]
}
9 changes: 9 additions & 0 deletions testdata/issues/issue352.wit.json.golden.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package issues:issue352;

interface i {
type a = result<tuple<bool, bool, bool>, s16>;
}

world w {
import i;
}
6 changes: 6 additions & 0 deletions tests/generated/wasi/sockets/v0.2.0/network/abi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions wit/bindgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,20 +1032,15 @@ func (g *generator) typeDefShape(file *gen.File, dir wit.Direction, t *wit.TypeD
case wit.Type:
return g.typeShape(file, dir, kind)
case *wit.Variant:
if kind.Enum() != nil {
// Variants that can be represented as an enum do not need a custom shape.
if len(kind.Types()) == 0 {
// Variants without associated types do not need a custom shape.
return g.typeRep(file, dir, t)
}
case *wit.Result:
if len(kind.Types()) == 0 {
// Results without associated types do not need a custom shape.
return g.typeRep(file, dir, t)
}
case *wit.Tuple:
if kind.Type() != nil {
// Monotypic tuples have a packed memory layout.
return g.typeRep(file, dir, t)
}
case *wit.Enum, *wit.Flags, *wit.List,
*wit.Resource, *wit.Own, *wit.Borrow, *wit.Stream, *wit.Future:
// Certain types do not need custom type shapes:
Expand Down