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
Typed MIR validator accepts a field projection through a reference with no deref #2269
Spec: §2.3 / D65 (one owner per fact; post-Sema invalid MIR is a compiler bug the validators must name).
On the D111 stack (before 9dabfbe) MIR lowered for p in ps.iter() over a Vec[Pair] (Pair: not Copy, no drop glue) as a view loop while Sema bound p by value. The body read p.a as the place _7.a where _7 held a &Pair. Codegen emitted getelementptr inbounds nuw ptr, ptr %1, i32 0, i32 0 and LLVM's SROA crashed (EXC_BAD_ACCESS in StructType::getTypeAtIndex).
Every tool said ok on that MIR: --validate-all, analyze audit:resolution, analyze audit:mir.
Repro (fails only on a compiler with the lowering bug; fixed in 9dabfbe):
type Pair { a: i64, b: i64 }
fn main:
var ps: Vec[Pair] = Vec.new()
for p in ps.iter():
if p.a != 7:
return
let x = 1
print(x)
Cause in the validator: mir_validate_place_type (src/MirCore.w) returns a place's stored place_sema_types entry when present, so the structural walk in mir_validate_place_prefix_type, which would find a PK_FIELD applied to a TY_REF base, never runs.
Expected: the typed validator compares a place's stored type with the type its projections derive from the local, and refuses a PK_FIELD/PK_INDEX applied directly to a reference or pointer (a missing PK_DEREF). The same check would also have caught a binding's local typed T receiving a &T value.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced in source. The typed validator walks a field projection through mir_validate_struct_field_type (src/MirCore.w:3639), which peels a reference or raw pointer and keeps going (:3642-3644: if tk == TypeKind.TY_REF or tk == TypeKind.TY_PTR: … return mir_validate_struct_field_type(mir_mod, inner, field_sym)). A field projection through a &Pair with no PK_DEREF is therefore accepted. The D65 field-place audit compares bases with references peeled too.
post-release: validator hardening; the lowering defect that exposed it is fixed.
Fixed in #3255 (6a905fd). Root cause: the typed validator read each place's declared type, so a field projection straight off a reference local looked well-typed. mir_validate_scalar_field_projection now refuses it: "projects field N of a reference with no dereference". Covered by the negative case in mir_structural_validator_test.w.
Activity
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced in source. The typed validator walks a field projection throughmir_validate_struct_field_type(src/MirCore.w:3639), which peels a reference or raw pointer and keeps going (:3642-3644:if tk == TypeKind.TY_REF or tk == TypeKind.TY_PTR: … return mir_validate_struct_field_type(mir_mod, inner, field_sym)). A field projection through a&Pairwith noPK_DEREFis therefore accepted. The D65 field-place audit compares bases with references peeled too.post-release: validator hardening; the lowering defect that exposed it is fixed.
Issues batch F: #1071 #984 #989 #2269 (#3255)
ehartford commentedon Nov 11, 2026
Fixed in #3255 (6a905fd). Root cause: the typed validator read each place's declared type, so a field projection straight off a reference local looked well-typed. mir_validate_scalar_field_projection now refuses it: "projects field N of a reference with no dereference". Covered by the negative case in mir_structural_validator_test.w.