Repository navigation
fix(wasm-codegen): preserve one-element array initializers - #1088
Conversation
Classify array defaults by their indexed representation so one-element arrays use the array encoder. Cover numeric initializer bytes, zero defaults, and repeated initialization. Fixes 8f4e#1060 Assisted-by: Codex
irimias57
left a comment
There was a problem hiding this comment.
Thank you for another excellent contribution, Nigel! This fix restores one-element array defaults across integer and floating-point formats and makes repeated initDefaults() calls dependable again. Thanks to this work, programs can trust their declared memory state instead of silently receiving zero or NaN, which makes the compiler and runtime substantially more reliable. The implementation is focused and the byte-level plus end-to-end coverage is excellent.
For a possible next contribution, I deliberately looked further back in the issue tracker: #551 — Add float32/float64 width checks to localSet is an older, currently unclaimed compiler bug from April. It has a well-defined semantic-analysis scope and clear test expectations, and resolving it would help us make progress on valuable issues that are less visible than the recent ones. No pressure—and thanks again!

Fixes #1060.
One element arrays were taking the scalar initialization path, turning integer initializers into zero and floating point initializers into NaN. The array check now uses the default's indexed representation.
Added 34 regression/control cases covering numeric formats, zero and omitted defaults, negative zero bytes and resetting after mutation. Float64 values are checked directly in memory. Twenty two cases will fail without the fix.
Validation on Node 24.16.0:
npx nx run-many --targets=test,typecheck --projects=@8f4e/wasm-codegen,@8f4e/compiler --parallel=1 --output-style=static- 536 tests passed. both type checks passed.