Skip to content

gen-c: a slice field takes the compound literal, except in a return - #3493

Merged
gHashTag merged 1 commit into
masterfrom
c/slice-field-literals
Sep 8, 2026
Merged

gen-c: a slice field takes the compound literal, except in a return#3493
gHashTag merged 1 commit into
masterfrom
c/slice-field-literals

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 8, 2026

Copy link
Copy Markdown
Owner

gen-c: a slice field takes the compound literal, except in a return

Closes #3492

Five passes in a row found their subject by SPLITTING a class rather
than by picking the biggest number. This one ran that instrument again
and then put it in the tool: c_error_classes.py prints diagnostics,
distinct lines and the RATIO together.

diags lines d/l class
2959 2224 1.33 use of undeclared identifier
1995 1960 1.02 call to undeclared function
750 668 1.12 expected expression
590 590 1.00 cannot use '__auto_type' with initializer list
199 199 1.00 incompatible integer to pointer conversion <- this
140 140 1.00 type name requires a specifier or qualifier

A ratio of 1.00 means no cascade -- every diagnostic is its own site.
Ranking by diagnostics alone had left redefinition in eighth place for
six passes at exactly 1.00, and it was the cleanest population there.

THE SUBJECT: (WeightBank){ .data = { 1, 2, 3, 4 } }. The field is
declared []i32, which lowers to int32_t*, and a brace list is not a
pointer. 199 sites in 9 files. The repair is the compound literal a call
argument already gets, with the element type taken from the FIELD's
declaration through the same helper.

THE POSITION HAD TO BE MEASURED BEFORE THE CODE WAS WRITTEN. A compound
literal at block scope dies with its block:

a local declaration 197 the literal outlives the statement
inside a return 4 the address of a local (#3445)
an assignment 1

So a flag records whether a return operand is being emitted -- and
THIS BACKEND HAS TWO RETURN ARMS, the statement and the expression. The
first version set the flag in the expression arm only, and the returned
struct literal took the cast anyway: the same "all the call sites"
defect the guard exists to prevent, one level up. A test covers the
nested case.

MEASURED, whole corpus, -ferror-limit=0:
errors 11 401 -> 11 191 (-210)
the class 199 -> 6
files better/worse 7 / 1
igla_race_bram_weights 209 -> 112
igla_race_ternary_inference 219 -> 123

THE ONE WORSE FILE IS UNMASKING, CHECKED RATHER THAN ASSUMED.
igla_race_backend 106 -> 107: one initializing ... with an expression of incompatible type disappeared because m now has a valid type, and
two appeared on a later line where out.assigns.len() became visible --
both of already-known families (-> and len).

Tests: 5 new, full suite 3548 passed 0 failed. Four mutants, all killed,
including the one that drops the statement-return flag. 8 stale seals
refreshed.

🤖 Generated with Claude Code

Closes #3492

Five passes in a row found their subject by SPLITTING a class rather
than by picking the biggest number. This one ran that instrument again
and then put it in the tool: `c_error_classes.py` prints diagnostics,
distinct lines and the RATIO together.

  diags  lines   d/l  class
   2959   2224  1.33  use of undeclared identifier
   1995   1960  1.02  call to undeclared function
    750    668  1.12  expected expression
    590    590  1.00  cannot use '__auto_type' with initializer list
    199    199  1.00  incompatible integer to pointer conversion  <- this
    140    140  1.00  type name requires a specifier or qualifier

A ratio of 1.00 means no cascade -- every diagnostic is its own site.
Ranking by diagnostics alone had left `redefinition` in eighth place for
six passes at exactly 1.00, and it was the cleanest population there.

THE SUBJECT: `(WeightBank){ .data = { 1, 2, 3, 4 } }`. The field is
declared `[]i32`, which lowers to `int32_t*`, and a brace list is not a
pointer. 199 sites in 9 files. The repair is the compound literal a call
argument already gets, with the element type taken from the FIELD's
declaration through the same helper.

THE POSITION HAD TO BE MEASURED BEFORE THE CODE WAS WRITTEN. A compound
literal at block scope dies with its block:

  a local declaration   197   the literal outlives the statement
  inside a `return`       4   the address of a local (#3445)
  an assignment           1

So a flag records whether a `return` operand is being emitted -- and
THIS BACKEND HAS TWO RETURN ARMS, the statement and the expression. The
first version set the flag in the expression arm only, and the returned
struct literal took the cast anyway: the same "all the call sites"
defect the guard exists to prevent, one level up. A test covers the
nested case.

MEASURED, whole corpus, -ferror-limit=0:
  errors            11 401 -> 11 191   (-210)
  the class            199 ->      6
  files better/worse     7 / 1
  igla_race_bram_weights 209 -> 112
  igla_race_ternary_inference 219 -> 123

THE ONE WORSE FILE IS UNMASKING, CHECKED RATHER THAN ASSUMED.
igla_race_backend 106 -> 107: one `initializing ... with an expression
of incompatible type` disappeared because `m` now has a valid type, and
two appeared on a later line where `out.assigns.len()` became visible --
both of already-known families (`->` and `len`).

Tests: 5 new, full suite 3548 passed 0 failed. Four mutants, all killed,
including the one that drops the statement-return flag. 8 stale seals
refreshed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gHashTag
gHashTag enabled auto-merge (squash) September 8, 2026 12:38
@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 12:38:38 UTC

Summary

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=bd400b48d2e2 != 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 93110e6 into master Sep 8, 2026
30 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: a slice field takes the compound literal, except in a return -- 199 sites at a 1.00 ratio

1 participant