Skip to content

fix(rust): a module-level bool was never in bool_vars (+11) - #3250

Merged
gHashTag merged 8 commits into
masterfrom
module-level-bools
Sep 5, 2026
Merged

gHashTag merged 8 commits into
masterfrom
module-level-bools

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

A spec may declare a bool beside its functions rather than inside one:

var full : bool = false;

It arrives as a ConstDecl whose type is bool. The emitter's bool_vars set is
cleared at the top of every function and refilled from that function's parameters
and locals, so a module-level bool was never in it — and the conditions came out as
integer comparisons:

if (full) != 0 {            // spec: if full {
while ((full) == 0) {       // spec: while !full {
full = ((full) == 0);       // spec: full = !full;

Isolated on a six-line pair, one variable changed

where the bool is declared emitted
module level if (full) != 0 { — wrong
inside a function if full { — correct

Only the scope differs. The knowledge exists and is applied in one scope and not the
other — the fifth instance of that shape this pass.

Both sibling backends already emit the condition verbatim.

Measured against a pinned binary

base (this branch's parent) 318
after 329
gained +11
new regressions 0

Predicted +6 to +13 before measuring, from the class size of 13.

The one regression showing against the 315 baseline is octree.t27, inherited from
#3247 in this stack and already stated there; this change adds none.

Provenance

Surfaced by the re-run of the E0308 fan-out against /tmp/t27c-pinned, after the
first run was discarded for measuring against a binary I rebuilt underneath it. Every
control in that run reports 0 occurrences among the 315 passing specs. The agent's
evidence named specs/fpga/testbench/fifo_tb.t27 lines 44 and 66 exactly, which is
what made the six-line isolation quick — my own first two probes did not reproduce it,
because I put the declaration inside a function both times.

Stacked: this branch sits on #3240 → #3242 → #3247. CI is currently stalled
repo-wide (29 runs queued, none in progress, nothing completing for 13+ minutes), so
none of the stack has landed yet.

Closes #3249

gHashTag and others added 4 commits September 5, 2026 10:12
compiler.rs:8322 maps "str" | "string" to []const u8 for Zig and
compiler.rs:18248 maps it to const char* for C. compiler.rs:24426 mapped it to
the owned String for Rust, and String is not constructible in a `const` item,
which is where the corpus mostly uses it:

    pub const DEFAULT_NOTEBOOK: String = "t27-QUEEN-BRAIN";
    error[E0308]: expected `String`, found `&str`

48 of the 75 specs whose first error was E0308 carried that mismatch.

Measured by name over all 650 corpus specs: rustc accepts 288 -> 314, +26, zero
regressions.

The judgement is stated rather than hidden. `&'static str` is narrower than
String -- a field of that type holds only a string living for the program -- and
that narrowing is what both siblings already chose, neither []const u8 nor
const char* owning its bytes. Zero regressions says nothing in the corpus needed
the owned form.

Also records the boundary my predictor from #3219 was missing. That rule ties a
fix's yield to the stub-bodied share of its class; this class is 3% stub-bodied
and I predicted +2..+8 against a measured +26. The rule holds for a fix repairing
a SIGNATURE while leaving a body, and not for one repairing a COMPLETE
DECLARATION: a const is correct or not on its own.

Seal and 92 drifted seals move in the same commit.

Closes #3239

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ositions (+1)

A spec field may be named `type`, `ref` or `match`. Those are Rust keywords and
the emitter wrote them bare, so the struct did not parse. `r#type` is the exact
spelling and needs no judgement.

The name is written in four places -- the field declaration, a field access, a
function parameter and a struct literal -- and repairing the first two changed
nothing beyond one spec. Repairing all four changed nothing further: the remaining
specs of the class carry other defects behind the keyword.

Measured by name over 650 specs: 314 -> 315, +1, zero regressions. The honest
measure here is closure, not yield: `found keyword `type`` as a first error goes
7 -> 1, and the residue is a different cause (keywords in TYPE position, from
#3225's list-valued declaration).

crate/self/Self/super are deliberately not escaped: `r#` is invalid for them, so
escaping would swap one parse error for another.

Also records a measurement flaw that has misled me three times: taking the LAST
numbered line of rustc's first error block reads back the SUGGESTION, since
suggestions render as numbered lines and come last. It produced a phantom
`pub struct ListNode<T>` earlier and made two specs here look already-repaired.

Closes #3241

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The mapper has both array branches and the Zig-shaped one throws the size away:
`[4]u8` becomes Vec<u8> while `[u8; 4]` becomes `[u8; 4]`. The right answer was
already forty lines above in the same function, whose comment records that only
the Zig spelling used to be handled. The two swapped places and one was left
behind.

Measured against a binary pinned at /tmp/t27c-pinned: 315 -> 318, +4, -1.

THE TRADE IS STATED RATHER THAN BURIED. The regression is octree.t27, whose field
is `children : [8]?OctNode` -- a fixed array of the struct it lives in. As
Vec<Option<OctNode>> it compiled because a Vec supplies indirection by accident
while discarding the length; as [Option<OctNode>; 8] it is honestly infinitely
sized. Neither is right: the correct Rust is [Option<Box<OctNode>>; 8], which
needs the enclosing type name inside a static function with 18 call sites.

A second regression was caught before shipping: reading everything in the brackets
as a size produced `[T; * as usize]` from `[*]T`, the many-item pointer. Guarded --
contents that are not a digit string or a plain identifier keep the unsized
lowering. Both regressions came from one omission: I enumerated the branches of the
bracket syntax and not the contents of the brackets.

Provenance: this cause was surfaced by a fan-out audit whose measurements I then
invalidated by rebuilding the compiler underneath it. One agent reported "THE RULER
MOVED UNDER ME" and was right; the workflow was stopped and its counts discarded.
Everything above is re-derived by hand against the pinned copy.

Closes #3246

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A spec may declare `var full : bool = false;` beside its functions rather than
inside one. It arrives as a ConstDecl whose type is bool, and `bool_vars` is
cleared at the top of every function and refilled from that function's parameters
and locals -- so a module-level bool was never in it, and the conditions came out
as integer comparisons: `if (full) != 0`, `while ((full) == 0)`,
`full = ((full) == 0)`.

Isolated on a six-line pair: the same declaration inside a function lowers
correctly and only the scope differs. Both sibling backends already emit the
condition verbatim. Fifth instance this pass of one shape -- the knowledge exists
and is applied in one place and not the other.

Measured against a pinned binary: 318 -> 329, +11, zero new regressions. Predicted
+6 to +13 from the class size of 13.

My own first two probes did not reproduce it, because I put the declaration inside
a function both times. Going to the case the evidence named beat reconstructing it.

Closes #3249

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

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 04:36:33 UTC

Summary

Status Count
Total Open PRs 20
PRs with Failing Checks 16
PRs with All Checks Green 4
READY 0
FAILING 16
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b52fccebfa30 != 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).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

# Conflicts:
#	.trinity/seals/ApbBridge.json
#	.trinity/seals/BoardMinimalXC7A100T.json
#	.trinity/seals/EmitterXDC.json
#	.trinity/seals/File.json
#	.trinity/seals/Git.json
#	.trinity/seals/GitDiff.json
#	.trinity/seals/GitOperations.json
#	.trinity/seals/Hir.json
#	.trinity/seals/Lexing.json
#	.trinity/seals/Linking.json
#	.trinity/seals/MAC_Testbench.json
#	.trinity/seals/NotebookLM.json
#	.trinity/seals/PhiRatio.json
#	.trinity/seals/PhiSplitOptimality.json
#	.trinity/seals/PhiUniversalAttractor.json
#	.trinity/seals/PinsIR.json
#	.trinity/seals/Project.json
#	.trinity/seals/SacredVerification.json
#	.trinity/seals/Session.json
#	.trinity/seals/Stdlib.json
#	.trinity/seals/TernaryIsa.json
#	.trinity/seals/Top_Level_Testbench.json
#	.trinity/seals/UART_Testbench.json
#	.trinity/seals/VcdConformanceCompare.json
#	.trinity/seals/Zamolodchikov4DConjecture.json
#	.trinity/seals/base-ring-32.json
#	.trinity/seals/base_base-ring-32.json
#	.trinity/seals/boards_BoardMinimalXC7A100T.json
#	.trinity/seals/cloud-railway-deploy.json
#	.trinity/seals/cloud_cloud-railway-deploy.json
#	.trinity/seals/compiler_Lexing.json
#	.trinity/seals/compiler_Linking.json
#	.trinity/seals/compiler_Stdlib.json
#	.trinity/seals/file_File.json
#	.trinity/seals/fpga_ApbBridge.json
#	.trinity/seals/fpga_FpgaStdlib.json
#	.trinity/seals/fpga_Hir.json
#	.trinity/seals/fpga_Memory.json
#	.trinity/seals/fpga_Stdlib.json
#	.trinity/seals/fpga_TernaryIsa.json
#	.trinity/seals/fpga_VcdConformanceCompare.json
#	.trinity/seals/git_Git.json
#	.trinity/seals/git_GitDiff.json
#	.trinity/seals/git_GitOperations.json
#	.trinity/seals/github::comments.json
#	.trinity/seals/github::issues.json
#	.trinity/seals/github::prs.json
#	.trinity/seals/github_github::comments.json
#	.trinity/seals/github_github::issues.json
#	.trinity/seals/github_github::prs.json
#	.trinity/seals/math_PhiSplitOptimality.json
#	.trinity/seals/math_PhiUniversalAttractor.json
#	.trinity/seals/memory_NotebookLM.json
#	.trinity/seals/nn_GatedLinearAttention.json
#	.trinity/seals/numeric_PhiRatio.json
#	.trinity/seals/physics_SacredVerification.json
#	.trinity/seals/physics_Zamolodchikov4DConjecture.json
#	.trinity/seals/pins_EmitterXDC.json
#	.trinity/seals/pins_PinsIR.json
#	.trinity/seals/race_igla-race-formal.json
#	.trinity/seals/server_Project.json
#	.trinity/seals/server_Session.json
#	.trinity/seals/testbench_MAC_Testbench.json
#	.trinity/seals/testbench_Top_Level_Testbench.json
#	.trinity/seals/testbench_UART_Testbench.json
#	bootstrap/stage0/FROZEN_HASH
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 06:42:59 UTC

Summary

Status Count
Total Open PRs 16
PRs with Failing Checks 14
PRs with All Checks Green 2
READY 0
FAILING 14
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b52fccebfa30 != 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).

# Conflicts:
#	.trinity/seals/MAC_Testbench.json
#	.trinity/seals/Top_Level_Testbench.json
#	.trinity/seals/testbench_MAC_Testbench.json
#	.trinity/seals/testbench_Top_Level_Testbench.json
#	bootstrap/stage0/FROZEN_HASH
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 07:41:36 UTC

Summary

Status Count
Total Open PRs 13
PRs with Failing Checks 11
PRs with All Checks Green 2
READY 0
FAILING 11
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b52fccebfa30 != 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).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 08:10:11 UTC

Summary

Status Count
Total Open PRs 12
PRs with Failing Checks 10
PRs with All Checks Green 2
READY 0
FAILING 10
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b52fccebfa30 != 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).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 08:11:39 UTC

Summary

Status Count
Total Open PRs 12
PRs with Failing Checks 11
PRs with All Checks Green 1
READY 0
FAILING 11
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b52fccebfa30 != 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).

@gHashTag
gHashTag merged commit 74be1ac into master Sep 5, 2026
29 of 30 checks passed
@gHashTag
gHashTag deleted the module-level-bools branch October 26, 2026 06:17
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.

A module-level bool is not in bool_vars, so its conditions lower to integer comparisons

1 participant