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
Struct literals silently accept unknown fields, duplicate fields, and default-expr type mismatches #632
Partly fixed in 2f4cac1: unknown fields and duplicate fields in struct literals are now rejected (§4.3), including on generic structs (unknown-field detection compares against declared field names, not the instantiated type). Verified: P { x:1, y:2, z:3 } → unknown field 'z'; P { x:1, x:2 } → duplicate field 'x'; generic Box { value: 5 } and defaulted Cfg { a: 1 } still compile. Fixtures: err_struct_literal_unknown_field.w, err_struct_literal_duplicate_field.w.
Remaining (keeping open): the third gap — a default-expr type mismatch at the type declaration (type P { x: i32 = "no" }) — is a decl-time check (SemaDecl.w:594-616) that needs the expression checker in the decl phase; not done here.
Completed in 6dbe626 (third of three checks). Unknown + duplicate fields landed earlier in 2f4cac1; this adds the decl-time default-expr check: type P { x: i32 = \"no\" } → field default type mismatch for 'x'. Literal adaptation still works (u8 = 200), generic decls are checked at literal sites. Fixture: err_struct_field_default_type_mismatch.w. Build + fixpoint + full suite green.
Activity
test: coverage-sweep batch 1 (#495 #496 #521 #518 #529 #492 #499)
ehartford commentedon Jul 4, 2026
Partly fixed in 2f4cac1: unknown fields and duplicate fields in struct literals are now rejected (§4.3), including on generic structs (unknown-field detection compares against declared field names, not the instantiated type). Verified:
P { x:1, y:2, z:3 }→unknown field 'z';P { x:1, x:2 }→duplicate field 'x'; genericBox { value: 5 }and defaultedCfg { a: 1 }still compile. Fixtures:err_struct_literal_unknown_field.w,err_struct_literal_duplicate_field.w.Remaining (keeping open): the third gap — a default-expr type mismatch at the type declaration (
type P { x: i32 = "no" }) — is a decl-time check (SemaDecl.w:594-616) that needs the expression checker in the decl phase; not done here.Easy sweep: real <| test, correct emit-c hint, struct-literal field v…
ehartford commentedon Jul 4, 2026
Completed in 6dbe626 (third of three checks). Unknown + duplicate fields landed earlier in 2f4cac1; this adds the decl-time default-expr check:
type P { x: i32 = \"no\" }→field default type mismatch for 'x'. Literal adaptation still works (u8 = 200), generic decls are checked at literal sites. Fixture:err_struct_field_default_type_mismatch.w. Build + fixpoint + full suite green.Fix #632 (final): struct field defaults are type-checked at declaration