You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ci] Two stale CIS_* layout comments in CiIR.w (DO_WHILE d2, VAR_DECL flags) #1022
AUDIT finding (read-only review at 450733e, verified against source).
Severity: Low (doc-only; producer/consumer agree, no behavioral impact).
Two enum comments in the CIS_* layout header disagree with the constructors
and printers:
src/CiIR.w:451 — CIS_DO_WHILE = 6 // d0 = body_block, d1 = cond_expr
omits d2, but do_while_stmt (:614-615) stores d2 = cond_setup, and the printer honors it on both paths
(src/CiPrint.w:304-316 compact, :907-919 pretty, with cond_setup != 0
guard). Fix: document d2 = cond_setup (0 if none).
src/CiIR.w:456 — CIS_VAR_DECL = 11 // ...; flags in extra is wrong: var_decl (:618-624) packs is_mut/has_init into f and passes it as
the flags argument to add, and the printer reads stmts.get_flags(id) (src/CiPrint.w:324-328, :1001-1005, :823-831).
Flags live in the flags column, never extra. Fix: "flags in flags
column (bit0=is_mut, bit1=has_init)".
Noted but NOT filed as defects: CiExprPool.set_type (:384-398) rebuilds
the whole types vec per call (O(n) + fresh allocation; live caller
src/CImport.w:6665) — perf-only observation, no incorrectness proven.
Verdict. Both documentation claims are established against current main; the lines are unchanged since the reported revision 450733e. This is a comment-accuracy defect with no behavioral impact, as the report says, so source evidence is sufficient and no execution is needed: the producer and both printers agree with each other and disagree only with the header comment.
Tested.main @ 5809ac1 (2026-09-14), source read; git log 450733e5..HEAD -- src/CiIR.w src/CiPrint.w shows only the byte_at/get mechanical sweep and unrelated edits, and both comment lines are byte-identical at 450733e.
Constructor packs is_mut (bit 0) and has_init (bit 1) into f and passes it as the fifth argument of add (:617-624); add pushes that argument to st.flags, a column distinct from st.extra (the pool has separate add_extra/get_extra and get_flags accessors, :563-567).
Printers read stmts.get_flags(id) at src/CiPrint.w:328 and :1009. Nothing reads extra for a CIS_VAR_DECL.
On the set_type note. Not a defect claim in the report and not assessed as one. For the record, CiExprPool.set_type does rebuild the whole types vector per call (src/CiIR.w:384-398); whether that matters is a profiling question, not a correctness one.
Spec/decisions. None apply; CiIR.w is an internal IR whose layout header exists to keep AGENTS.md's "confirm AST layouts before editing" rule honest. A wrong layout comment is exactly the trap that rule warns about, which is why the fix is worth the two lines.
Related PRs. None touch these comments.
Recommendation. Fix, two-line doc change with no build impact. Acceptance criteria: line 451 reads d0 = body_block, d1 = cond_expr, d2 = cond_setup (0 if none); line 456 reads ...; flags column: bit0 = is_mut, bit1 = has_init and no longer mentions extra. Optional: a one-line CiIR self-check that asserts each CIS_* constructor's use of d2/flags/extra matches a table, so the header cannot drift again.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced; both comments are unchanged. src/CiIR.w:528 says CIS_DO_WHILE = 6 // d0 = body_block, d1 = cond_expr while do_while_stmt (:696-697) stores cond_setup in d2. src/CiIR.w:533 still says "flags in extra" for CIS_VAR_DECL.
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced
Verdict. Both documentation claims are established against current
main; the lines are unchanged since the reported revision 450733e. This is a comment-accuracy defect with no behavioral impact, as the report says, so source evidence is sufficient and no execution is needed: the producer and both printers agree with each other and disagree only with the header comment.Tested.
main@ 5809ac1 (2026-09-14), source read;git log 450733e5..HEAD -- src/CiIR.w src/CiPrint.wshows only thebyte_at/getmechanical sweep and unrelated edits, and both comment lines are byte-identical at 450733e.Claim 1,
CIS_DO_WHILEomitsd2. Confirmed.src/CiIR.w:451saysd0 = body_block, d1 = cond_expr.do_while_stmt(body, cond, cond_setup)callsself.add(CIS_DO_WHILE, body, cond, cond_setup, 0)(:614-615).let cond_setup = stmts.get_d2(id)atsrc/CiPrint.w:307and:914.Claim 2,
CIS_VAR_DECL"flags in extra" is wrong. Confirmed.src/CiIR.w:456.is_mut(bit 0) andhas_init(bit 1) intofand passes it as the fifth argument ofadd(:617-624);addpushes that argument tost.flags, a column distinct fromst.extra(the pool has separateadd_extra/get_extraandget_flagsaccessors,:563-567).stmts.get_flags(id)atsrc/CiPrint.w:328and:1009. Nothing readsextrafor aCIS_VAR_DECL.On the
set_typenote. Not a defect claim in the report and not assessed as one. For the record,CiExprPool.set_typedoes rebuild the wholetypesvector per call (src/CiIR.w:384-398); whether that matters is a profiling question, not a correctness one.Spec/decisions. None apply;
CiIR.wis an internal IR whose layout header exists to keep AGENTS.md's "confirm AST layouts before editing" rule honest. A wrong layout comment is exactly the trap that rule warns about, which is why the fix is worth the two lines.Related PRs. None touch these comments.
Recommendation. Fix, two-line doc change with no build impact. Acceptance criteria: line 451 reads
d0 = body_block, d1 = cond_expr, d2 = cond_setup (0 if none); line 456 reads...; flags column: bit0 = is_mut, bit1 = has_initand no longer mentionsextra. Optional: a one-lineCiIRself-check that asserts eachCIS_*constructor's use ofd2/flags/extramatches a table, so the header cannot drift again.ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced; both comments are unchanged.src/CiIR.w:528saysCIS_DO_WHILE = 6 // d0 = body_block, d1 = cond_exprwhiledo_while_stmt(:696-697) storescond_setupin d2.src/CiIR.w:533still says "flags in extra" forCIS_VAR_DECL.post-release: comment-only, no behavior.
Issues batch A: #1021 #1022 #1023 #2760 #3057 #3060 #3086 #3113 #3114 (…
ehartford commentedon Nov 11, 2026
Merged to main ae20d89 (#3248): the two CIS_* layout comments in CiIR.w state d2 = cond_setup and the flags column.