fix(wasm-codegen): preserve one-element array initializers by jinchuntan · Pull Request #1088 · 8f4e/8f4e · GitHub
Skip to content

fix(wasm-codegen): preserve one-element array initializers - #1088

Merged
andorthehood merged 1 commit into
8f4e:mainfrom
jinchuntan:fix/single-element-array-defaults
Oct 18, 2026
Merged

andorthehood merged 1 commit into
8f4e:mainfrom
jinchuntan:fix/single-element-array-defaults

Conversation

@jinchuntan

@jinchuntan jinchuntan commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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.
  • Biome checks on the three changed files and the repository pre commit checks pass.

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
@andorthehood andorthehood added compiler Compiler, tokenizer, codegen, and language-semantics work contributor labels Oct 18, 2026

@irimias57 irimias57 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@andorthehood andorthehood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again!

@andorthehood
andorthehood merged commit 8e46b07 into 8f4e:main Oct 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler Compiler, tokenizer, codegen, and language-semantics work contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve initializers for one-element arrays

3 participants