gen-c: an enum member is a constant, not a field access - #3468
Merged
Conversation
Closes #3467 enum Trit { pos, neg, zero } var t = Trit.pos; __auto_type t = Trit.pos; error: unexpected type name 'Trit': expected expression C has no `Type.member`. The constant `gen_c_enum` emits is `TRIT_POS` -- the type and the member, both upper-cased -- and the use site never learned to spell it that way. The declaration and the use had two spellings and nothing brought them together. Only C is wrong. `gen-rust` emits `Trit::pos` and `gen-zig` emits `Trit.pos`, each correct for its language: three backends agree and one had no answer, which is the shape of every repair in this campaign. MEASURED, whole corpus, -ferror-limit=0: errors 14040 -> 13340 unexpected type name 'Trit' 642 -> 12 files better / worse 15 / 0 `vsa/ops` 569 -> 99, `demos/jones_topology_decision_gate` 106 -> 40, `fpga/mac` 84 -> 25. THE MEASUREMENT CAME FIRST AND EARNED THE CODE. Printing the sites by shape showed 604 distinct lines all of one form, which is what made a single rewrite plausible before it was written. The family itself was found only because the previous pass stopped re-counting one class and ranked them all. HALF THE FAMILY IS A DIFFERENT DEFECT and is filed rather than assumed fixed. `use of undeclared identifier 'POS'` (412) and `'NEG'` (319) are unchanged -- 731 errors over 422 lines, in `(a == NEG) ? ...` shapes. Those bare names appear NOWHERE in the specs: the compiler's own lowering introduces them without the type prefix. A MUTANT SURVIVED ON A GUARD THAT LOOKED DECORATIVE. Keying the rewrite on either side -- the member's name OR the base's -- passed every test, because no test had a member whose name was also an enum type. `struct S { Colour : i32 }` beside `enum Colour` is that case, and `s.Colour` must stay a field access. Added; the mutant dies. Three others were already dead. 17 seals refreshed in the same commit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3467
C has no
Type.member. The constantgen_c_enumhas been emitting all alongis
TRIT_POS— the type and the member, both upper-cased — and the usesite never learned to spell it that way.
Only C is wrong
gen-rustTrit::posgen-zigTrit.posgen-cTrit.posMeasured —
-ferror-limit=0unexpected type name 'Trit'vsa/ops569 → 99 ·jones_topology_decision_gate106 → 40 ·fpga/mac84 → 25. The largest single repair this campaign has made — and the family
was found only because the previous pass stopped re-counting one class and
ranked them all.
The measurement came first and earned the code: printing the sites by shape
showed 604 distinct lines all of one form, which is what made a single
rewrite plausible before it was written.
Half the family is a different defect, and is filed as such
use of undeclared identifier 'POS'(412) and'NEG'(319) are unchanged— 731 errors over 422 lines, in
(a == NEG) ? …shapes. Those bare namesappear nowhere in the specs: the compiler's own lowering introduces them
without the type prefix. Same symptom family, different repair.
A mutant survived on a guard that looked decorative
Keying the rewrite on either side — the member's name or the base's —
passed every test, because no test had a member whose name was also an enum
type.
s.Colourmust stay a field access. Added; the mutant dies.Full suite: 2652 passed, 0 failed. 17 seals refreshed in the same commit.