lang: opt-in UFCS — ufcs-marked fns + alias dot-dispatch, generic binding via receiver; one binding builder for plan-side generic returns

This commit is contained in:
agra
2026-06-11 17:04:51 +03:00
parent 84e0fb0752
commit a47ea1416e
27 changed files with 316 additions and 137 deletions

View File

@@ -1,20 +1,24 @@
# 0119 — UFCS dot-call on a GENERIC free function: "unresolved '<name>'"
> **RESOLVED — not a bug** (2026-06-11, Agra language ruling, same
> session). Dot-form UFCS on generic free functions is NOT the language
> contract: UFCS free-function dot-dispatch is the annotated mechanism
> (`name :: ufcs target;`, concrete targets), and the FLUENT spelling
> for free functions is the pipe operator — `xs |> first_of()` desugars
> at parse time to `first_of(xs)`, which dispatches generics through
> the normal monomorphization machinery (verified:
> `context.allocator |> create(Session)` works). specs.md §UFCS
> corrected (it overstated "works with ... generic functions" for the
> dot form). No compiler change. MEM Phase 2.2 unblocked — helpers
> shipped as free functions with the direct + `|>` contract
> (examples/0838-memory-helpers.sx pins both spellings).
> Residual corner (not contracted, unfiled): a `ufcs` ALIAS naming a
> generic target also doesn't dot-dispatch; file separately if ever
> wanted.
> **RESOLVED** (2026-06-11, same session — Agra language ruling + the
> opt-in implementation). Final model: free-function dot-calls are
> OPT-IN. `name :: ufcs (params) { body }` (new declaration form) and
> `name :: ufcs target;` (alias) both opt in; a PLAIN fn never
> dot-dispatches (tailored diagnostic steers to direct / `|>` /
> marking it ufcs). Generic ufcs fns dispatch via dot with the
> receiver participating in `$T` binding; a protocol-typed receiver
> dispatches its own methods first and falls through to ufcs fns
> (`context.allocator.create(Session)` works). Bonus root-cause fix:
> plan-side `inferGenericReturnType` now delegates to the SAME
> `buildTypeBindings` the monomorphizer uses, so structured generic
> params (`[]$T`) type direct calls correctly too (was a `T{}` stub
> through print's Any boxing — pre-existing). The previously-implicit
> unannotated dot-dispatch was REMOVED (inverted vs the model);
> in-tree reliance was 6 example files (audited; migrated to marked
> form), zero in m3te/game. specs.md §UFCS rewritten around the
> opt-in matrix. Regression: examples/0053-basic-ufcs-opt-in.sx +
> 1166-diagnostics-ufcs-not-opted-in.sx; mem helpers marked ufcs
> (0838 pins dot + pipe + direct). Suite 585/585.
## Symptom