Description
echo "`wit-bindgen-go version` | `tinygo version` | `wasmtime --version` | `uname -m`"
wit-bindgen-go version v0.6.2 | tinygo version 0.37.0 darwin/arm64 (using go version go1.24.3 and LLVM version 19.1.2) | wasmtime 32.0.0 (d3054950c 2025-04-21) | arm64
wit-bindgen-go represents the WIT definition result<tuple<tuple<u8, s32>>, s32> with the following type definition: cm.Result[[1]cm.Tuple[uint8, int32], [1]cm.Tuple[uint8, int32], int32]. Initializing and retrieving a data value of this type produces an incorrect value.
Note: similar to #344, it seems that the result shape is causing the high 24 bits of the result's error case to be ignored. However, the fix in #349 does not prevent the unexpected behavior seen in this test case.
Component model bindings are generated for the following WIT world:
world foo {
... wasi imports ...
type alias = result<tuple<tuple<u8, s32>>, s32>;
export wasi:cli/run@0.2.0;
}
The following Go program implements foo. It initializes a value of type Alias and prints its value.
func main() {
want := int32(-1)
var alias foo.Alias = cm.Err[foo.Alias](want)
got := *alias.Err()
println("want:", want)
println("got:", got)
}
When the program above is compiled to a Wasm component using TinyGo and executed using Wasmtime, an incorrect value is printed.
Steps to reproduce
Here is a zipped directory that reproduces the bug: test-case.zip
- Unzip
test-case.zip
cd go-result-tuple-tuple-corruption
- Build and run with
./verify.sh
Expected behavior
The printed values should be the same:
Actual behavior
The values differ:
Additional context
The Go source program was derived from programs generated by a differential testing framework for WIT binding generators. The WIT definition was derived from a test case produced by wit-smith.
Description
wit-bindgen-gorepresents the WIT definitionresult<tuple<tuple<u8, s32>>, s32>with the following type definition:cm.Result[[1]cm.Tuple[uint8, int32], [1]cm.Tuple[uint8, int32], int32]. Initializing and retrieving a data value of this type produces an incorrect value.Note: similar to #344, it seems that the result shape is causing the high 24 bits of the
result's error case to be ignored. However, the fix in #349 does not prevent the unexpected behavior seen in this test case.Component model bindings are generated for the following WIT world:
The following Go program implements
foo. It initializes a value of typeAliasand prints its value.When the program above is compiled to a Wasm component using TinyGo and executed using Wasmtime, an incorrect value is printed.
Steps to reproduce
Here is a zipped directory that reproduces the bug: test-case.zip
test-case.zipcd go-result-tuple-tuple-corruption./verify.shExpected behavior
The printed values should be the same:
Actual behavior
The values differ:
Additional context
The Go source program was derived from programs generated by a differential testing framework for WIT binding generators. The WIT definition was derived from a test case produced by wit-smith.