Skip to content

codegen(wasm): print(String) emits an invalid module (lowered as integer print) #850

Backlog

Description

@hyperpolymath

print with a String argument produces an invalid core-wasm module. The failure is loud: the module fails validation, so nothing runs.

pub fn main() -> () { print("hi"); println(""); }

affinescript compile succeeds. bun run out.wasm then fails with CompileError: WebAssembly.Module doesn't validate: attempt to use unknown local 3, the number of locals is 3. Re-verified on main-based build 161eaaf.

Cause, found by the #836 work (PR #841): the wasm print arm in lib/codegen.ml lowers print as an integer print, but its type is String -> Unit.

Fix: lower print(String) like the string half of println, or refuse print on non-Int arguments by name until then. Add a fixture.


Generated by Claude Code

Activity

  1. added
    architecture
    bindings
    enhancement
    on Dec 1, 2026
  2. whatproblem-ai commented on Dec 1, 2026

    @whatproblem-ai

    Problem: On the wasm backend, print with a String argument (print("hi")) is lowered as an integer print in lib/codegen.ml, even though its type is String -> Unit. affinescript compile succeeds, but the emitted module fails validation (attempt to use unknown local 3, the number of locals is 3), so nothing runs. Reproduced on 161eaaf.
    Expected: print(String) either compiles to a valid module that prints the string, lowered like the string half of println, or is rejected by name at compile time for non-Int arguments. A fixture covers it.


    Clarity: 94%. Clear enough to work on.

    ⌨️ Commands · 💬 Have feedback? Tell us · 🎯 New here? Add WhatProblem to your repo · 🔒 Privacy

  3. added
    bug
    migration
    priority:p2
    scope:repo
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecturebindingsbugenhancementmigrationpriority:p2scope:repo

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions