Skip to content

gen-c: give an unannotated array literal a real element type - #3460

Merged
gHashTag merged 1 commit into
masterfrom
parity/round-seven
Sep 8, 2026
Merged

gen-c: give an unannotated array literal a real element type#3460
gHashTag merged 1 commit into
masterfrom
parity/round-seven

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Closes #3459

__auto_type w = { (W){ .code = 1 }, (W){ .code = 2 } };
error: cannot use '__auto_type' with initializer list in C

1729 of them — the largest single error class in the generated C corpus,
more than twice the next (992). Under clang's default cap the same class reads
as 97.

Why the existing repair missed it

W699 rung 3 already handles this and required the array literal to carry its
own extra_type. [W{…}, W{…}] does not — the type sits on the child,
each element being a named struct literal.

The same arm carried the is_primitive gate, third instance of W583: it
lists only the integer scalars, so [_]f64{…} would have emitted f64 x[2].

Measured — -ferror-limit=0

before after
errors 15021 14738
__auto_type with initializer list 1729 1401
files that compile 302 303
files better 15

igla/race/ternary_gemm 562 → 437 · ternary_mac 208 → 168 ·
math/property_test_template 43 → 5.

Eight files rose, and all eight are unmasking — checked

An error-typed variable silences every diagnostic about its uses. While w
had no valid type, clang said nothing about w.field or w[i].len.

  • four name an element type absent from the generated header
    (TernaryWeight, Cell, Assignment) — a separate pre-existing defect;
  • four surface real downstream errors: no member named 'len' in 'struct Item', member reference type 'Item *' … did you mean to use '->'.

In both groups the declaration is now correct and the count rose because clang
can finally see past it. This is the sharpest form of the non-monotonicity from
the previous pass.

A mutant survived because my test used the wrong spelling

Restoring the is_primitive gate broke nothing — the test declared
var x : [2]f64, an annotated local, which takes a different branch
entirely. [_]f64{…} is the form that reaches this arm.

mutant dead tests
condition narrowed back 1
is_primitive gate restored 0 → 1 after the spelling was fixed
element type not recovered 1

Full suite: 2634 passed, 0 failed. 38 seals refreshed in the same commit.

Residual

var x = [1.0, 2.0] — a bare list of numeric literals with no element type
anywhere — still takes __auto_type. 1401 of the class remain, and
recovering a type there needs literal-kind inference rather than a lookup.
Named rather than left implied.

Closes #3459

    var w = [W{.code=1}, W{.code=2}];
    __auto_type w = { (W){ .code = 1 }, (W){ .code = 2 } };
    error: cannot use '__auto_type' with initializer list in C

1729 of them: the LARGEST single error class in the generated C corpus, more
than twice the next (992 `expected expression`). Under clang's default cap the
same class reads as 97.

The repair existed -- W699 rung 3 -- and required the array literal to carry
its own `extra_type`. `[W{...}, W{...}]` does not: the type sits on the CHILD,
each element being a named struct literal. The condition now looks there, and
the element type is taken from the first element when the array has none.

The same arm carried the `is_primitive` gate, THIRD instance of W583. It lists
only the integer scalars, so `[_]f64{...}` would have emitted `f64 x[2]`.

MEASURED, whole corpus, -ferror-limit=0:

    errors                                15021 -> 14738
    __auto_type with initializer list      1729 ->  1401
    files that compile                      302 ->   303
    files better                             15

EIGHT FILES' COUNTS ROSE AND ALL EIGHT ARE UNMASKING, checked rather than
assumed. An error-typed variable silences every diagnostic about its USES:
while `w` had no valid type, clang reported nothing about `w.field` or
`w[i].len`. Four of the eight name an element type that is absent from the
generated header entirely -- a separate defect -- and the other four surface
real downstream errors: `no member named 'len' in 'struct Item'`, `member
reference type 'Item *' ... did you mean to use '->'`. In both groups the
declaration is now correct and the count rose because clang can see past it.

A MUTANT SURVIVED BECAUSE MY TEST USED THE WRONG SPELLING. Restoring the
`is_primitive` gate broke nothing: the test declared `var x : [2]f64`, an
ANNOTATED local, which takes a different branch entirely. `[_]f64{...}` is the
form that reaches this arm. Rewritten, and the mutant dies. Three mutants,
three dead.

Residual, named rather than implied: `var x = [1.0, 2.0]` -- a bare list of
numeric literals with no element type anywhere -- still takes `__auto_type`.
1401 of the class remain, and recovering a type there needs literal-kind
inference rather than a lookup.

38 seals refreshed in the same commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gHashTag
gHashTag enabled auto-merge (squash) September 8, 2026 03:44
@github-actions

github-actions Bot commented Sep 8, 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 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-08 03:44:46 UTC

Summary

Status Count
Total Open PRs 16
PRs with Failing Checks 13
PRs with All Checks Green 3
READY 2
FAILING 13
PENDING 0
NO CHECKS YET 0

These columns do not partition: 2 + 13 + 0 + 0 = 15, and there are 16 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=cc0a3676c563 != 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 2428a07 into master Sep 8, 2026
29 of 33 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.

gen-c: an unannotated array literal becomes __auto_type x = { … }, the corpus's largest error class

1 participant