#2710 refuted rewriting the shape; #2711 showed the neighbouring fix was blocked by the same undecided question. The question is answerable by measuring the corpus rather than by choosing.
Across all 497 specs, every struct containing a field named enum:
|
count |
|
enum is the sole field, value a bare-identifier list |
9 |
[Ascending, Descending] |
enum is the sole field, value empty |
12 |
no variant names exist |
enum is the sole field, value a quoted list |
1 |
["RED", "BLACK"] |
enum alongside other fields |
1 |
tools/schema.t27 ParameterSchema |
Zero overlap. The one genuine record — the refuter's counter-example, whose enum field holds a type — is exactly the case a sole-field rule excludes. So:
A struct whose sole field is enum with a bare-identifier list is an enum declaration. An enum field alongside others is a field.
That is decided by the corpus, not by preference, and it unblocks both fixes at once.
Landed together, because separately each regresses
fold_sole_enum_field — 9 declarations become real Zig enums.
- A keyword is a legal struct field name when a colon follows — 23 fields in 21 specs, 22 of them
enum. The colon is the discriminator so enum ErrorCode { in the braced dialect is not read as a field.
fold_enum_type_marker — the other generator shape, enum_type : "enum", values : , Zeros : Auto, .... 4 declarations, none of which could have a dependent: they emitted enum_type: enum, values: void, which is not valid Zig at all.
Alone, (2) cost five specs (#2711). With (1) it costs none, because those five stop being structs.
Measured:
|
before |
after |
| ast-check valid |
290 |
293 |
| ast-check errors |
594 |
591 |
| specs worse / better |
|
0 / 3 |
| parse gate |
105 |
105 events / 0 lost, holds |
ParameterSchema keeps @"enum": ?[any]. SortOrder is enum { Ascending, Descending }. PaddingMode is enum { Zeros, Reflect, Replicate, Circular }.
The pinning tests now fail, as they should
The five specs' tests read @typeInfo(X).@"struct".fields.len and @FieldType(X, "Ascending") — written by my own agents two iterations ago to move a flat assertion count, and they pinned the accidental struct shape. They now report access of union field 'struct' while field 'enum' is active.
That is the fix working. Updating them to assert enum properties is the next commit, not a separate concern — a defect repair that leaves its pinning tests red is only half done.
Not folded
The 12 declarations whose enum field is empty carry no variant names in the source. A rule could only produce enum {}, which recovers no meaning. They need the specs repaired upstream.
#2710 refuted rewriting the shape; #2711 showed the neighbouring fix was blocked by the same undecided question. The question is answerable by measuring the corpus rather than by choosing.
Across all 497 specs, every struct containing a field named
enum:enumis the sole field, value a bare-identifier list[Ascending, Descending]enumis the sole field, value emptyenumis the sole field, value a quoted list["RED", "BLACK"]enumalongside other fieldstools/schema.t27ParameterSchemaZero overlap. The one genuine record — the refuter's counter-example, whose
enumfield holds a type — is exactly the case a sole-field rule excludes. So:That is decided by the corpus, not by preference, and it unblocks both fixes at once.
Landed together, because separately each regresses
fold_sole_enum_field— 9 declarations become real Zig enums.enum. The colon is the discriminator soenum ErrorCode {in the braced dialect is not read as a field.fold_enum_type_marker— the other generator shape,enum_type : "enum", values : , Zeros : Auto, .... 4 declarations, none of which could have a dependent: they emittedenum_type: enum, values: void, which is not valid Zig at all.Alone, (2) cost five specs (#2711). With (1) it costs none, because those five stop being structs.
Measured:
ParameterSchemakeeps@"enum": ?[any].SortOrderisenum { Ascending, Descending }.PaddingModeisenum { Zeros, Reflect, Replicate, Circular }.The pinning tests now fail, as they should
The five specs' tests read
@typeInfo(X).@"struct".fields.lenand@FieldType(X, "Ascending")— written by my own agents two iterations ago to move a flat assertion count, and they pinned the accidental struct shape. They now reportaccess of union field 'struct' while field 'enum' is active.That is the fix working. Updating them to assert enum properties is the next commit, not a separate concern — a defect repair that leaves its pinning tests red is only half done.
Not folded
The 12 declarations whose
enumfield is empty carry no variant names in the source. A rule could only produceenum {}, which recovers no meaning. They need the specs repaired upstream.