Open
Description
Zig Version
0.14.0-dev.878+c6995e6de
Steps to Reproduce and Observed Behavior
The following main.zig compiles and runs just fine on my default target (x86_64 linux):
const std = @import("std");
const T = packed struct(u64) {
foo: bool = false,
_: u63 = 0,
};
pub fn main() !void {
const t: T = .{};
std.debug.print("default {any}\n", .{ t });
}
working version:
$ zig run main.zig
default main.T{ .foo = false, ._ = 0 }
But if I compile and run this on wasm the compile succeeds, but wasmtime fails to run it:
$ zig build-exe main.zig -target wasm32-wasi && wasmtime ./main.wasm
Error: WebAssembly translation error
Caused by:
Invalid input WebAssembly code at offset 8333: type mismatch: expected i64, found i32
It looks like fmt has caused a similar problem in the past (#15609) but I think the details are different in this time, so I filed a new bug.
Dropping the packed
or reducing the u64
to u32
avoids the problem.
Some additional details:
$ wasmtime --version
wasmtime-cli 23.0.1
wasm-decompile doesn't like it either:
$ wasm-decompile ./main.wasm
./main.wasm:0002093: error: type mismatch in call, expected [i32, i64, i32, i32, i32] but got [i32, i32, i32, i32, i32]
./main.wasm:00066d9: error: type mismatch at end of function, expected [] but got [i32]
Expected Behavior
wasm target should work like the native target