Skip to content

codegen: structural miscompile — region + let-bound String.new/String.len emits invalid wasm (type mismatch, empty stack) #348

Description

@hyperpolymath

Found while building the #251 seam-conformance test (2026-07-07). This program:

module seam_access

fn main(): I32 = region r {
    let s = String.new@r("hi") in String.len(s)
}

fails ephapax compile with:

Error: emitted wasm failed structural validation: type mismatch: expected i32 but nothing on stack (at offset 0x2b2)

i.e. the pipeline parses and typechecks it, then codegen emits structurally invalid wasm — caught only by the in-process wasmparser assertion. fn echo(s: String): String = s compiles fine, so the trigger is somewhere in the region + let-bound String.new@r/String.len combination on the v2 surface path.

Note the corpus ratchet gate (#343) records that no conformance/valid string program currently compiles, so this codegen path has no green coverage; whichever fix lands should flip at least one string fixture into tests/eph-corpus-compiles.txt.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesenhancementNew capability or improvement to existing behaviour

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions