feat(producer): third typedwasm.ownership producer in Zig — the language-agnosticism proof#200
Merged
Merged
Conversation
…ccess + skip_declaration bug fix
Takes example 03/04 system bodies from representative stubs to REAL
typed loads/stores with pinned access sites, executed correctly in a
real engine.
- parser: general statement lowerer (tried after the exact reader/
writer shapes; bails to the stub on anything unsupported). Covers
`let [mut] x: ty = expr`, assignment, `if`/`else`, `while` (block/
loop/br_if), `return [expr]`, indexed `region.get/set $h[i] .f`
(base + i*stride), `cast<i32|f32|f64>`, typed expression lowering
with precedence (cmp > add > mul > primary) and no implicit
promotion. Each region param is copied to a base local ONCE in the
prologue so own/&mut discipline holds under per-path use counting
regardless of how many accesses follow.
- IR: Op gains locals/control-flow/arithmetic/conversion instructions;
Func gains `locals` (emitted via Function::new_with_locals_types).
- REAL BUG FIX: skip_declaration skipped a balanced `{...}` block and
then KEPT SCANNING for a `;` — so example-04's top-level
`invariant ... { ... }` blocks swallowed every following declaration:
ex04's functions were never parsed at all (its "6/6 corpus
round-trip" was regions-only). Now returns after a block-shaped
declaration; ex04 parses 4 functions, 3 lower for real.
- tests/example04.rs: real-lowering assertions for ex03/ex04 bodies
(pinned sites), all-verifier-passes gate (validate + L7/L10 + L2
bounds + L2 access-typing), and a wasmi execution gate proving
while/if-else/indexed/cast lowering COMPUTES correct results
(sum-abs + f32-scale over a cell array).
Workspace: 166 tests, 0 failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…age-agnosticism proof typed-wasm's claim is "independent compile target", not "companion library of two sibling languages". This lands the proof: a producer sharing NO ancestry with AffineScript (OCaml), Ephapax (Rust), or the in-tree Rust codegen — ffi/zig/src/twasm_producer.zig hand-assembles a core wasm module byte-by-byte and attaches the typedwasm.ownership section per the documented wire format. - Zig generator: buildModule(allocator, double_use) emits consume(x: Linear i32) using its param once (honest) or twice (a wasm-level double-free). Deterministic (test-asserted); 4 Zig tests wired into `zig build test`; `zig build gen-fixtures` regenerates the committed fixtures. - Fixtures committed under crates/typed-wasm-verify/tests/fixtures/zig_producer/ (74/77 bytes, provenance README, capture 2026-07-07 zig 0.15.2) — same pattern as the c5_real AffineScript corpus. - tests/third_producer_zig.rs: the Zig bytes validate as wasm, the honest module PASSES L7/L10, extract_exports reads the carrier exactly as a first-party one (consume: [Linear] -> Unrestricted), and the double-use mutant is REJECTED (LinearUsedMultiple). Workspace: 170 tests, 0 failures; zig build test green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Increment 3 of 3 on the independence construction path.
A compile target is only language-agnostic if a toolchain with no shared code can participate. This lands that proof:
ffi/zig/src/twasm_producer.zighand-assembles a core wasm module byte-by-byte (no wasm-encoder, no typed-wasm-verify encoders, no sibling-compiler code) and attachestypedwasm.ownershipper the documented wire format.typed-wasm-verifythen:extract_exports→consume: [Linear] → Unrestricted),LinearUsedMultiple— a wasm-level double-free).Fixtures are committed under
crates/typed-wasm-verify/tests/fixtures/zig_producer/with a provenance README (capture 2026-07-07, zig 0.15.2;zig build gen-fixturesregenerates; generator determinism is test-asserted) — the same pattern as the c5_real AffineScript corpus. The Zig generator's own 4 tests are wired intozig build test.170 workspace tests, 0 failures;
zig build testgreen.🤖 Generated with Claude Code