You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
emit-C: full-compiler --emit-c fails with 'map.insert expects three arguments' (one-arg set-style insert unclassified) #668
Compiling the full compiler root with --emit-c fails before emitting output:
$ ./out/release/bin/with build src/main.w --emit-c -o /tmp/main.c
error: C emission failed: map.insert expects three arguments
error: build failed
Facts
Reproduces identically with the current release binary AND the impl-kind bridge binary on the committed tree (b987f97, verified in a clean worktree) — pre-existing, not introduced by the 2026-07-13/14 tool-campaign commits.
The C emitter's CcBuiltin.MAP_INSERT handler (src/CCodegen.w:5909) requires argc >= 3 (receiver, key, value). Somewhere in the compiler's own source a one-argument set-style .insert(key) (e.g. __bg_in.insert(key) in src/SemaCheck.w:14654, HashSet-style) is classified as MAP_INSERT and rejected. The LLVM backend compiles the same call fine, so this is an emit-C backend gap, not a frontend bug.
The :test graph's emit-C smoke target passes; only the full-compiler emit-C path hits this, so the gate stays green while the cross-compilation story is broken for the compiler itself.
Expected
Either CCodegen supports the one-argument insert form the LLVM backend supports (set-insert / default-value insert), or the classification distinguishes set-inserts from map-inserts before arity-checking.
Spec ref: --emit-c is the documented cross-compilation path (docs/with-specification.md, CLI); the compiler is a valid With program, so it must be emittable.
Fixed in a7efb23 — and the thread ran deeper than the filed error. Three emit-C gaps stood between --emit-c and the compiler's own source, plus a fourth the new regression case caught before it could ship:
The filed defect: MAP_INSERT required argc ≥ 3, rejecting HashSet's one-arg insert(key). The two-arg form now synthesizes a present-marker value, mirroring the LLVM backend's set branch (CodegenDispatch's recv_base_sym == sym_hashset path).
A latent silent-wrongness bug found verifying Type resolution corruption when single source file exceeds ~14K lines #1: the emitted set compiled but returned wrong results — MAP_NEW sized keys via hashmap_key_tid (which didn't understand HashSet → i64 fallback = 8 bytes) while insert/contains used the raw operand type (i32 = 4 bytes), so insert and lookup hashed different garbage bytes. hashmap_key_tid now understands HashSet, and a shared map_call_key_tid prefers the receiver's canonical key type in all five key-consuming handlers — the LLVM backend's key-coercion discipline.
The same gap in the three duplicated place-tid walkers (place_tid, place_ref_target_tid, place_tid_no_infer): t.1 rendered correctly but typed as unknown, dodging str-equality lowering into a raw C == on with_str. Caught by the new smoke case at C-compile time. (That triple-duplicated walk is Cathedral sweep: audit each compiler file for per-path logic that should be a single source of truth #651 material — noted there.)
Result: with build src/main.w --emit-c — which failed immediately when this was filed — now emits the full compiler (1.84M lines of C). Notably, #619's >32GiB OOM did not fire; emission completed under the default limit.
Remaining, tracked forward: the emitted compiler C does not yet cc-compile — two error classes: lazy map-init writes through const-qualified receiver pointers (18+ sites, parameter-emission mechanism), and a missing with_str_split_vec extern in the C preamble. Both are next on the emit-C thread; posting the retest + new barrier on #619.
Regression pinning: the :test EMIT-C smoke gains an emit-c-collections case running set insert/remove (i32 and str keys), map insert/get, and tuple field/index/destructure through the full emit → cc → run chain with output compared against the LLVM backend's.
Gates: build ok, FIXPOINT, analyze audit:all violations=0, all test targets green, EMIT-C smoke ok (including the new case), test-green + last-green recorded.
Activity
emit-C: set inserts, canonical map key types, tuple projections (#668)
ehartford commentedon Jul 17, 2026
Fixed in a7efb23 — and the thread ran deeper than the filed error. Three emit-C gaps stood between
--emit-cand the compiler's own source, plus a fourth the new regression case caught before it could ship:MAP_INSERTrequired argc ≥ 3, rejecting HashSet's one-arginsert(key). The two-arg form now synthesizes a present-marker value, mirroring the LLVM backend's set branch (CodegenDispatch'srecv_base_sym == sym_hashsetpath).MAP_NEWsized keys viahashmap_key_tid(which didn't understand HashSet → i64 fallback = 8 bytes) while insert/contains used the raw operand type (i32 = 4 bytes), so insert and lookup hashed different garbage bytes.hashmap_key_tidnow understands HashSet, and a sharedmap_call_key_tidprefers the receiver's canonical key type in all five key-consuming handlers — the LLVM backend's key-coercion discipline.PK_TUPLE_INDEXprojections were unsupported in the place renderer — the next hard failure after Type resolution corruption when single source file exceeds ~14K lines #1 (unsupported place projection kind 4).place_tid,place_ref_target_tid,place_tid_no_infer):t.1rendered correctly but typed as unknown, dodging str-equality lowering into a raw C==onwith_str. Caught by the new smoke case at C-compile time. (That triple-duplicated walk is Cathedral sweep: audit each compiler file for per-path logic that should be a single source of truth #651 material — noted there.)Result:
with build src/main.w --emit-c— which failed immediately when this was filed — now emits the full compiler (1.84M lines of C). Notably, #619's >32GiB OOM did not fire; emission completed under the default limit.Remaining, tracked forward: the emitted compiler C does not yet cc-compile — two error classes: lazy map-init writes through
const-qualified receiver pointers (18+ sites, parameter-emission mechanism), and a missingwith_str_split_vecextern in the C preamble. Both are next on the emit-C thread; posting the retest + new barrier on #619.Regression pinning: the
:testEMIT-C smoke gains anemit-c-collectionscase running set insert/remove (i32 and str keys), map insert/get, and tuple field/index/destructure through the full emit → cc → run chain with output compared against the LLVM backend's.Gates: build ok, FIXPOINT, analyze audit:all violations=0, all test targets green, EMIT-C smoke ok (including the new case), test-green + last-green recorded.