Skip to content

t27b: == and != between pointers and optional pointers compare addresses, from a t27 plan (Closes #7742) - #7831

Open
gHashTag wants to merge 13 commits into
masterfrom
t27b-ptr-eq-7742
Open

gHashTag wants to merge 13 commits into
masterfrom
t27b-ptr-eq-7742

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #7742. Part of #6063 (t27b coverage, item C10 of #6488). Split from #7737 (#7744).

Decision

In Zig 0.16, == and != between two pointers, two optional pointers, or one of each, to one pointee type, compare the addresses, null being 0. Both operands are evaluated, left first. t27b now does the same. An optional pointer's address is its payload when its flag is set and 0 when not. Each operand is pinned in a frame slot in source order, so a bounds check on either side still runs first and once. Every other comparison keeps its path: the optional-of-scalar compare, null_compare, enums and integers.

Before this, t27b refused all three shapes: ExprBinary(?T) "of two optionals", ExprBinary(?T) "a value that has effects", and type mismatch "== on a pointer". The corpus case is gen_hazard_pointers.t27 (hazard1 != hazard2, &registry.hazards[i] == hazard). Its reference pass is for the right reason: HazardRegistry_acquire returns an element of the caller's registry.

Evidence

All on the t27c Railway lab (zig 0.16.0, t27c from master).

  • Reference: t27c test-report gives 3/3 pass, 15 runtime asserts on conformance/pointer_equality.t27, and 6/6 on ptr_eq_plan.t27. Both have 0 vacuous passes.
  • Mutants: 7 of 7 for the plan, and 10 of 10 for the conformance spec, both by the reference and by t27b.
  • Seals: both new specs are sealed (seal --save, then --verify: all hashes MATCH).
  • Corpus, master t27b against this branch's over the same tree (t27c lab, qemu-aarch64, master 4d7d2d3): only conformance/pointer_equality.t27 moves (ExprBinary(?T) -> pass). The new plan passes under both. Nothing else changes: lifting the plain-pointer type mismatch unblocks no other corpus file.
  • With t27b: ?*anyopaque and @ptrFromInt to an optional pointer lower from a t27 plan (Closes #7737) #7744's glue as well (both branches applied to one tree on the t27c lab), gen_hazard_pointers.t27 passes 4/4 under t27b test --check, with 16 runtime asserts.
  • cargo test --release -p t27b (t27c lab, x86_64 interpreter): 119 passed, 0 failed on the lane head; 127 passed, 0 failed on the merge with master 1083135.

Lines by file

kind file lines
hand-written Rust cli/t27b/src/lower.rs +39 (the mount, the call in the binary operator, ptr_compare, ptr_word)
hand-written Rust test cli/t27b/tests/source.rs +8
generated gen/rust/tri/t27b/ptr_eq_plan.rs +19
.t27 specs/tri/t27b/ptr_eq_plan.t27 +70
.t27 specs/tri/t27b/conformance/pointer_equality.t27 +77
data 2 seals under .trinity/seals/ +40
data docs/reports/t27b_expectations.json +6 -4
prose AGENTS.md +5 -1

Hand-written total +47 (budget 80; at most 40 per file). Master's check_budget() and check_all() from gen/c/policy/own_language.c both exit 0 on this diff. wc -l over master 1083135: cli/t27b/src/*.rs 15191 -> 15230, cli/t27b/src/*/*.rs 1202 (unchanged), cli/t27b/tests/*.rs 8119 -> 8127.

Ledger

Only the rows that move: gen_hazard_pointers.t27 goes from blocked to pass (with #7744, now on master), and conformance/pointer_equality.t27 and ptr_eq_plan.t27 are new rows that pass. On master 1083135's ledger: pass 921 -> 924, max_not_pass 36 -> 35.

Receipt

Signed lane receipt from the t27b lab (#7686), compared on the lab from /work/t27 with /work/t27c-master corpus-receipt compare BASE HEAD --challenge-head <mine>:

  • Lane head c8e2cf5 against base 4d7d2d3: IMPROVED_ONLY, exit 3. lane improved for pointer_equality.t27 and ptr_eq_plan.t27. No other file changed. The head run has 0 mismatches and 0 reference disagreements, cargo test passes 139 with 0 failed, and there are no ratchet findings on these files.

Masters 14e1c7b (#7447, the bit_cast plan), 81da894 (#7769), bbb77f0 (#7744, this lane's sibling) and 1083135 (the f32 rounding ports) were merged in after that. With #7744's glue in the tree, gen_hazard_pointers.t27 now passes, and its row moves to pass here. On the t27c lab, the merge with bbb77f0 gave cargo test 126 passed, 0 failed, and gen_hazard_pointers.t27 4/4 under t27b test --check. The corpus run, master bbb77f0's t27b against that merge's over the same tree, moves exactly gen_hazard_pointers.t27 and pointer_equality.t27 (ExprBinary(?T) -> pass). The merge with 1083135 gives cargo test 127 passed, 0 failed, and the same --check results. A receipt for that head is requested from the lab.

Generated with Claude Code

claude and others added 5 commits October 8, 2026 15:50
…loses #7742)

specs/tri/t27b/conformance/pointer_equality.t27 pins what the reference does
with the comparisons of gen_hazard_pointers.t27: two optional pointers
(`hazard1 != hazard2`, both null and not), a pointer with a bounds-checked
index against an optional pointer, either way round
(`&registry.hazards[i] == hazard`), and two plain pointers, one with a
run-time index. In Zig 0.16 they compare addresses, null being 0.

t27c test-report (zig 0.16.0, t27c lab): 3/3 pass, 0 vacuous, 15 runtime
asserts. 10 of 10 mutants are killed by the reference and by t27b. Sealed
on the t27c lab (seal --save, then --verify: all hashes MATCH).

Part of #6063.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ses, from a t27 plan (Closes #7742)

The decision is specs/tri/t27b/ptr_eq_plan.t27, mounted through t27c
gen-rust (gen/rust/tri/t27b/ptr_eq_plan.rs): `==` / `!=` with a pointer or
an optional pointer on each side, one pointee type, compares the addresses.
An optional pointer's address is its payload when its flag is set and 0
when not; each operand is pinned in a frame slot in source order, so a
bounds check on either side still runs first and once. Every other
comparison keeps its path (the optional-of-scalar compare, null_compare,
enums, integers).

Before, t27b refused all three shapes: ExprBinary(?T) "of two optionals",
ExprBinary(?T) "a value that has effects", and type mismatch "`==` on a
pointer".

Plan: 6/6 pass under t27c test-report, 0 vacuous; 7 of 7 plan mutants
killed. gen-rust output is what the lab's t27c prints; sealed (seal
--verify: all hashes MATCH).

Glue: lower.rs +39 (the mount, the call in the binary operator,
ptr_compare, ptr_word). Tests: cli/t27b/tests/source.rs +8 runs the
conformance spec.

Corpus (t27c lab, qemu-aarch64, master t27b and this branch's over the same
tree): only the conformance spec moves (to pass). With #7737's glue as
well, gen_hazard_pointers.t27 passes 4/4 under `t27b test --check`.

Part of #6063.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From master's side, no conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From master's side, no conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oses #7742)

docs/reports/t27b_expectations.json: `tri t27b ratchet --bless --accept-new`
over master d42df2b's lab run with this branch's t27b verdicts for the
files it changes (t27c lab corpus, master 4d7d2d3's t27b against this
branch's over the same tree) and the reference verdicts t27c test-report
gave the new specs, composed onto master's ledger with only these rows:
conformance/pointer_equality.t27 and ptr_eq_plan.t27, new, pass. pass
898 -> 900, max_not_pass stays 39.

gen_hazard_pointers.t27 needs #7737's glue too; whichever of #7744 and this
PR lands second moves its row to pass.

AGENTS.md: this branch's clause, `wc -l` over master 4d7d2d3:
cli/t27b/src/*.rs 14995 -> 15034, src/*/*.rs 1166 (unchanged),
cli/t27b/tests/*.rs 7987 -> 7995.

Part of #6063.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 14:32:16 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 48
PRs with All Checks Green 2
READY 1
FAILING 48
PENDING 0
NO CHECKS YET 0

These columns do not partition: 1 + 48 + 0 + 0 = 49, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=39fa3908f9fd != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

This was referenced Oct 8, 2026
From master's side (#7904's tool-card tests and others; no t27b code changed, the conflict is the ledger only).
docs/reports/t27b_expectations.json: master's ledger plus this branch's three
rows, recomposed as before (gen_hazard_pointers.t27 -> pass, two new pass
rows): pass 942 -> 945, max_not_pass 33 -> 32. AGENTS.md: master's remainder plus this branch's clause,
re-measured with `wc -l` over master 4daabae: src/*.rs 15227 -> 15266,
src/*/*.rs unchanged, tests/*.rs 8164 -> 8172.

Merged-tree checks on the t27c lab: cargo test --release -p t27b 130
passed, 0 failed; under `t27b test --check` gen_hazard_pointers.t27 (4/4),
pointer_equality.t27, ptr_eq_plan.t27 and opaque_pointer.t27 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 22:40:15 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 41
PRs with All Checks Green 9
READY 3
FAILING 41
PENDING 0
NO CHECKS YET 0

These columns do not partition: 3 + 41 + 0 + 0 = 44, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c0ade9e73e4 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

This was referenced Oct 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27b: == and != between pointers and optional pointers compare addresses

2 participants