Skip to content

fix(rust): a field named type is a keyword, and the name has four positions (+1) - #3242

Merged
gHashTag merged 5 commits into
masterfrom
rust-keyword-field-names
Sep 5, 2026
Merged

gHashTag merged 5 commits into
masterfrom
rust-keyword-field-names

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 5, 2026

Copy link
Copy Markdown
Owner

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. Rust's raw-identifier syntax
r#type is the exact spelling and needs no judgement.

Four positions, and the first two were not enough

The name is written in four places and repairing two of them changed nothing beyond
the first spec:

position
struct field declaration pub type: T,
field access x.type
function parameter pub fn f(type: T)
struct literal Event { type: v }

Measured: 314 → 315, +1, 0 regressions — the same +1 after two positions and after
all four, because the remaining specs of the class carry further defects behind the
keyword.

The class is closed, which is the honest measure here

found keyword \type`as a **first** error: **7 → 1** across the corpus. The residue under "found keyword" is a different cause —enum(5),struct(2),mod` (1) — those
are keywords in type position, from the list-valued declaration of #3225, not field
names.

crate, self, Self and super are deliberately not escaped: r# is invalid
for them, so escaping would swap one parse error for another. None occurs as a field
name here, and if one appears it stays bare and fails visibly.

A measurement flaw that has now misled me three times

To find the failing source line I was taking the last numbered line of rustc's
first error block. rustc renders its suggestion as a numbered line, and suggestions
come last — so I read back the corrected code as if it were the defect:

179 |     return Event { id: 0, r#type: event_type, ...   <- what I extracted (the fix)
179 |     return Event { id: 0, type: event_type, ...     <- the actual line

It produced a phantom pub struct ListNode<T> earlier, and here it made two specs look
already-repaired. The correct extraction is the first numbered line after -->.

Closes #3241

gHashTag and others added 2 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>
@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 03:51:45 UTC

Summary

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=99577856cf3d != 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 04:18:24 UTC

Summary

Status Count
Total Open PRs 21
PRs with Failing Checks 17
PRs with All Checks Green 4
READY 0
FAILING 17
PENDING 0

Seal Status

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

…names

# Conflicts:
#	.trinity/seals/File.json
#	.trinity/seals/Git.json
#	.trinity/seals/GitDiff.json
#	.trinity/seals/GitOperations.json
#	.trinity/seals/Hir.json
#	.trinity/seals/VcdConformanceCompare.json
#	.trinity/seals/file_File.json
#	.trinity/seals/fpga_Hir.json
#	.trinity/seals/fpga_VcdConformanceCompare.json
#	.trinity/seals/git_Git.json
#	.trinity/seals/git_GitDiff.json
#	.trinity/seals/git_GitOperations.json
#	.trinity/seals/race_igla-race-formal.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:34:03 UTC

Summary

Status Count
Total Open PRs 17
PRs with Failing Checks 11
PRs with All Checks Green 6
READY 0
FAILING 11
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=99577856cf3d != 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 1d70d57 into master Sep 5, 2026
35 of 37 checks passed
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 field named type is a Rust keyword, and the name is written in four places

1 participant