// Regression: type-descriptor field offsets were built with 64-bit pointer // sizes on the wasm32 target. // // A struct containing a pointer (string, slice, func value) got a descriptor // whose field offsets assumed 8-byte pointers. A value returned across a // package boundary goes through the structural codec, which walks that // descriptor - so on wasm every field after the first was written at the // 64-bit offset and the caller read the 32-bit slot: zero, or the wrong word. // Within a single package the call is direct and the codec is not involved, // which is why only the cross-package case shows the mismatch. // // Fixed in: _mxc_stage4/ir_descriptors.mx (descPtrSize, typeDescSize, // typeDescAlign). Legacy already reads the pointer size from LLVM's // TargetData, so both compilers now describe the target's layout. package main import "tests/regressions/should_compile/struct_field_offsets_wasm/lib" func main() { w := lib.New(`["REQ","x"]`) println("mw I:") println(w.I) println("mw S:") println(w.S) p := lib.NewPair("hi") println("pair I:") println(p.I) println("pair S:") println(p.S) n := lib.NewIntFirst("hi") println("intfirst I:") println(n.I) println("intfirst S:") println(n.S) }