INTERCEPTS conflates two concepts: compiler-supplied bodies vs optimisation of a real body #41
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Surfaced during the intrinsic-bodies milestone (audit of
caa3618).The codegen intercept registry
crates/ailang-codegen/src/intercepts.rs::INTERCEPTSmixes two semantically distinct kinds of entry:Intrinsic-backed (14 entries): the fn has no real body — the source carries
(intrinsic)(Term::Intrinsic) and the compiler supplies the implementation. The 7 prelude Eq/Ord instance methods, the 6float_*fns, and theanswerratifier. Closing the honesty-rule infraction on these is exactly what intrinsic-bodies did.Optimisation-only (5 entries):
lt__Int,le__Int,gt__Int,ge__Int,ne__Int. These intercept the monomorphised__Intspecialisation of the polymorphic free fnslt/le/gt/ge/ne, which carry real, honest bodies in the prelude (ne = (app not (app eq x y)); the four ordering helpers are(match (app compare x y) ...)). Those bodies are lowered for every non-Intinstantiation; only theIntspecialisation is intercepted for a faster directicmp. No lie, no(intrinsic)marker.The two are structurally indistinguishable in the registry today — both are just
Interceptrows. Theintrinsic-bodies.2bijection pin (intercepts_bijection_with_intrinsic_markers) papers over the difference with a hardcoded 5-nameOPTIMISATION_ONLYallowlist (a comment-level distinction, not a type-level one).Possible direction (not committed): give
Interceptan explicit kind field (e.g.IntrinsicBackedvsOptimisation) so the registry is self-describing and the bijection pin derives the allowlist from the data instead of a hand-maintained name list. A stale allowlist (a name added to one class but the pin not updated) would then be impossible by construction — the same make-illegal-states-unrepresentable discipline intrinsic-bodies applied to bodies.Why deferred, not done now: out of scope for intrinsic-bodies (which is about the body surface, not the registry's internal taxonomy). Splitting the registry is its own focused change. The allowlist + the stale-allowlist guard in the pin contain the risk in the meantime.
No urgency: the bijection pin is green and guards both directions. This is a clarity/robustness improvement, not a correctness bug.
Verification 2026-06-02: Core concern still holds.
Intercept(crates/ailang-codegen/src/intercepts.rs) still has nokind/enum field, and the bijection pinintercepts_bijection_with_intrinsic_markersstill papers over the distinction with the hardcoded 5-nameOPTIMISATION_ONLYallowlist (lt/le/gt/ge/ne __Int). Count drift: the registry has grown well past the original 14 intrinsic-backed entries (RawBuf intercepts landed since), so the taxonomy now spans intrinsic-backed + optimisation-only + RawBuf-runtime entries — which strengthens, not weakens, the make-the-kind-explicit case. Still an idea, no urgency; the pin is green.