49. Int stops one above -2^63 (codegen and performance, 2026-11-21)
- 49.1
Int.MINis-(2^63 - 1)in the compiler too, and-2^63is noIntanywhere. The spec settled this (1.1,design/spec/11-types.md); the implementation still hadInt.MIN = i64::MIN. Nowreadrejects-9223372036854775808in bothcpl runand the C++, arithmetic and narrowing (Int(x)fromI128/F64,floor/ceil/round,bit_ceil) that would produce it stop with the usual overflow error, and constants folded by codegen agree. This frees the pattern as?Int'snoneeverywhere.Int.MIN / -1isInt.MAX, soedivandemodlose their-1guards. Reverse: setcpl_ir::INT_MINback toi64::MINand drop the!= i64::MINfilters;?Intthen needs 16 bytes outside proven tables again.
- 49.2 Float to
Intis exact at the ends in both builds. The interpreter's bound was±9.2e18, the C++'s±2^63, soInt(9.21e18)disagreed; both now accept exactly the floats strictly between-2^63and2^63, andfloor/ceil/roundshare the check (they cast unchecked in C++, undefined past the range). Reverse: none needed; any bound must be the same in both.
- 49.3
Bitsetwords areU64. A word with only bit 63 set is-2^63, which is noInt, and the old helpers built it fromInt.MIN. WithU64(wrapping, logical shifts) the helpers for bit 63 disappear. Reverse: none whileIntstays symmetric.
- 49.4 Every
?Intiscpl::OptInt, 8 bytes, with-2^63asnone. With 49.1 the pattern is free everywhere, so locals, fields, arguments, lists, maps and tables all use it; the proof that a table never storesInt.MIN(niche::packed_tables) and the pack/unpack plumbing in codegen are gone. Reason: values take the fewest bytes their types allow, and a layout that depended on a whole-program proof changed with unrelated edits. Reverse: mapTy::Opt(Int)back tostd::optional<ll>innames.rs(and restore the table proof to keep tables packed). Cost: theNichetemplate (about 1 KB) now appears in every program that touches a?Int, including a passingxs.first; 65 small ports grew more than 5% and the baseline was rewritten. The template was trimmed (unused>,<=,>=, a duplicate constructor); over the corpus the median went 10,345 -> 10,899 B, p95 28,064 -> 27,734 B, max 58,744 -> 58,821 B, none over 64 KB.