fix(operators): the five B2 repairs — the law enforced where Rust used to guess #74
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/074-fix-operators-the-five-b2-repairs-the-law-enfo"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fix(operators): the five B2 repairs — the law enforced where Rust used to guess
Along the way:
Touches 63 files:
Prelude.ck,handoff.md,plan.md,src/rust/crates/ck_codegen/src/arg.rs,src/rust/crates/ck_codegen/src/binding.rs,src/rust/crates/ck_codegen/src/call.rsand 57 more.A clear improvement. The change in
src/rust/crates/ck_driver/src/compile/mock.rsis the part I would have argued for.@ -654,0 +710,4 @@/// seeds plus this op's own parameters (E5 — `fn info(msg: String)` seeds `msg`/// at `String`), each keyed by its name-token span. The two never collide (a/// param cannot re-use a sibling state field's name — E0305).fn op_body_seeds(op_body_seedsreads, decides and writes in one function. The deciding part is the piece I would want to test on its own. Worth splitting?Second read on
src/rust/crates/ck_driver/src/compile/mock.rs. Nothing to add.Split. The decision in
op_body_seedsis a pure function now, with its own tests insrc/rust/crates/ck_driver/src/compile/mock.rs.The `byte` scalar leaf ({size 8, unsigned int}, its own identity though it shares u8's machine word) was declared in Floor.ck/Floor.ckh but inert: zero trait impls, zero corpus usage, so no program could ever construct one (primitives-slice audit finding). Mirror the full u8 coherence roster for byte in both Preludes (repo-root Prelude.ck and its tests/corpus/stdlib twin, kept identical): Add/Sub/Mul/Div/Rem/Neg/Equals/Ord/BitAnd/BitOr/BitXor/ BitNot/Shl/Shr, each a one-line body naming the same Floor leaf the u8 row calls (iadd/isub/imul/udiv/urem/ineg/ieq+ine/ult+ule+ugt+uge/band/bor/bxor/ bnot/ishl/ushr) — 14 rows added per file, nothing invented beyond what u8 already has. Verified empirically (built ckc, ran with absolute paths against the real stdlib) that the generic Floor pipeline already treats byte exactly like u8 end to end — codegen derives the Cranelift type from the leaf's repr {size,signed,float}, never the name — so no Rust change and no Floor.ck/ Floor.ckh edit was needed. Finding worth recording: Floor's `where T is A or B or ...` union bounds are not currently enforced by the type checker at all (the lift step drops any union bound, ck_types::predicate.rs) — byte's calls type-check today because the bound is a no-op, not because byte and u8 are considered equivalent. Out of scope here (no Rust changes requested), but future union-bound enforcement will need byte added to Floor's where-lists to keep compiling. New corpus stone tests/corpus/byte_ops exercises every added row through real operator syntax (+ - * / % unary- == != < <= > >= & | ^ unary~ << >>, never a direct Floor:: call) on 12::byte/5::byte — chosen so every op has a non-trivial, discriminating result. Eighteen checks chain to a distinct failure code (1..18) or exit 42; confirmed freestanding (no NEEDED, no undefined symbols, no libc/ck_rt, 6752 bytes). Runtime-gated by ck_driver/tests/byte_ops_run.rs (modeled on int_convert_run.rs) and registered in RUNTIME_TESTED (runtime_registry.rs) so the app cannot regress to diagnostics-only. Gates: cargo fmt --check clean; cargo clippy --all-targets -D warnings clean; cargo build --workspace clean; cargo test -p ck_driver --test architecture 21/21; cargo test -p ck_driver --test stdlib_type_clean green; cargo test --workspace --no-fail-fast: only the 3 expected soft-assert canaries FAILED inside captured stdout (soft_asserts/freestanding_write/string_eq negative fixtures), every real test-binary result ok.