From acb464f9577cfaa9c8e7815eea42cd4cfb5b3ad5 Mon Sep 17 00:00:00 2001 From: Scott Scoble Date: Wed, 6 May 2026 05:14:33 -0700 Subject: [PATCH] fix(wasm): remove spurious i32.const from uncompiled assignment placeholders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Undcompiled map/record/unrecognized assignments emitted (i32.const 1) placeholders that left values on the WASM stack. Combined with the default return i32.const 1 at end of function, this caused type mismatch errors (expected [], got [i32, i32] or [i32]). Fix: make uncompiled assignments emit comment-only output with no stack effect. Scalar assignments already work correctly since emitExpr feeds into global.set which consumes the value. Closes #9 WASM E2E portion — parser fix for precondition:/postcondition: keyword handling still needed. --- compiler/src/generators/wasm.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/src/generators/wasm.ts b/compiler/src/generators/wasm.ts index 0b0d3f8..700ddc1 100644 --- a/compiler/src/generators/wasm.ts +++ b/compiler/src/generators/wasm.ts @@ -357,18 +357,16 @@ function emitAssignment( const keyExpr = mapAssign[2]; // For now: map_set(map_handle, key_handle, value_handle) // This needs boxing; simplified version just marks as stub - return `;; Map assignment not yet compiled: ${target} := ${expr}\n` + - ` (i32.const 1)`; + return `;; Map assignment not yet compiled: ${target} := ${expr}`; } // Record field assignment: accounts[id].field := expr const recordAssign = target.match(/^(\w+)\[(.+)\]\.(\w+)$/); if (recordAssign && maps.has(recordAssign[1])) { - return `;; Record field assignment not yet compiled: ${target} := ${expr}\n` + - ` (i32.const 1)`; + return `;; Record field assignment not yet compiled: ${target} := ${expr}`; } - return `;; Unrecognized assignment target: ${target}\n (i32.const 1)`; + return `;; Unrecognized assignment target: ${target}`; } // =============================================================================