Post #1966340
2026-04-28 03:59 UTC
I realized this some months ago but don't think I mentioned it here:
Let variables with exactly-once assignment analysis can support simple type inference just like expression-oriented initialization. You don't need HM-style constraint solving. It works in a single-pass compiler assuming your subtyping rules are simple enough in their interaction with multiple branches, but that same caveat applies to expression-oriented initialization.
Replies (1)
-
@pervognsen@mastodon.social 2026-04-28 04:01
The simplest version of the single-pass algorithm (with no support for subtyping) is that the first (in source order) assignment to a let variable fixes the variable's type and any other assignments to the same variable (necessarily on disjoint paths) check against that type. Anyway, I used to think that one objective advantage of expression-oriented initialization was its simpler interaction with type propagation, but this shows that isn't actually a real difference.