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
An integer literal at a distinct-integer demand must coerce: fn none() -> CiStmtId: 0 is refused ("return type mismatch"), so the tree casts 0 as CiStmtId 690 times #2567
The comparison x != 0 is accepted (the literal takes the distinct type from the other operand), but the same literal at a declared return type is refused, and so is 3 at a parameter of type Id.
Expected
The declared return type is the demand, the same way an annotated binding, a parameter or a field is: an integer literal at a distinct integer demand takes that type. Spec §3 (defaults pick representations, never meanings); mission: never write what the compiler already knows. Eric (2026-10-22): a declared return type is exactly the case where the function states the type instead of the body casting.
Cost today
src/CImport.w alone carries 690 casts of the shape 0 as CiStmtId / as CiExprId / as CiTypeId, nearly all return 0 as CiStmtId under a declared -> CiStmtId. The matching compare-side ceremony, (x as i32) != 0 (449 sites across the migrator files), compiles without the cast today and is swept separately.
Fix
Sema's literal typing at a demand: when the demanded type is a distinct integer type whose base accepts the literal, the literal has the distinct type (return position, parameter, binding annotation, field initializer, match arm value). Then sweep the 690 casts with a compiler-driven rewrite and add the pattern to the ceremony census.
Fixed in #2580 (c7fa606), D153: an unsuffixed literal where a distinct type over a number is demanded takes the distinct type (return, binding, parameter, field, negation, float distinct, untyped constant), fit-checked at the underlying width; codegen lowers the constant at the representation. Fixtures behav_2567, err_2567. The 690-cast sweep in src/CImport.w is a follow-up.
Activity
Phase 4: BTreeMap and BTreeSet over the M*LIB B+tree (D151); D152; D1…
Seven compiler fixes: literals at distinct demands (D153), element-pl…
ehartford commentedon Oct 23, 2026
Fixed in #2580 (c7fa606), D153: an unsuffixed literal where a distinct type over a number is demanded takes the distinct type (return, binding, parameter, field, negation, float distinct, untyped constant), fit-checked at the underlying width; codegen lowers the constant at the representation. Fixtures behav_2567, err_2567. The 690-cast sweep in src/CImport.w is a follow-up.