Design decisions

116. Type arguments on a receiver fill a list-form fn's generics; they never pick another fn (2026-11-21)

  • Decision. Graph<V>.undirected(pairs) resolves to the same undirected_of_pairs / _of_triples fn as Graph.undirected(pairs), in the checker (list_form) and in lowering (list_form_call). Type arguments on the receiver fill the fn's like-named generics (V), so Graph<V>.undirected([(1, 2)]) is an error saying it wants a List<(V, V)>. A pattern form naming fields (for (u, v, w: weight) in edges) was considered and not added: names are written once where the data enters (read<[m](u: V, v: V, w: Int)>()), and no dream or friction report uses it (open question in spec/lib/rationale/graphs.md).
  • Also (no new rule). The checker's existing positional-to-named fit ((V, V) fits (u: V, v: V)) now reaches through optionals (?(Int, Int) fits ?(a: Int, b: Int)), and lowering retypes in place a value whose type differs from the wanted one only in tuple field names (same_cells, through arrays, optionals and lists). Both back ends hold tuples and records the same way, as std::tuple in C++ and a tuple value in the interpreter, so this is free. [n](Int, Int) into [n](a: Int, b: Int) used to be rejected in lowering. Swapped field types still do not fit (tests/diagnostics/named_tuple_cells_keep_their_order). Reverse by dropping same_cells from lower/mod.rs and lower/stmt.rs and the Optional/Optional arm from Ty::fits_in.
  • Why. Four dreams (cf2035f, cf2057e2, cf2150f, cf2152g) write Graph<V>.undirected(read<[n](V, V)>()). That skipped the pair-list fn and fell through to the declared-edge-domain form, so writing a type argument changed which fn ran.
  • Reverse. Restore the bare-name-only list_form in cpl-check/src/check/call.rs, and inline list_form_call back into the unparameterized branch of cpl-ir/src/lower/call.rs.