Skip to content

D119 Amendment 1 (#2311): Vector[T, N] element-first + array-length generics - #2380

Merged
ehartford merged 2 commits into
fix-2358-builtin-arityfrom
d119a1-vector-length-generics
Oct 13, 2026
Merged

ehartford merged 2 commits into
fix-2358-builtin-arityfrom
d119a1-vector-length-generics

Conversation

@ehartford

@ehartford ehartford commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Implements #2311 (D119 Amendment 1, ruled in #2376). Stack layer 2 on #2378.

Vector[T, N] — element first, like [T; N]; Mask[N, W] keeps its count first as the ruling left it; aliases unchanged. The internal type (d0 lane, d1 count) does not move: resolvers, frozen twins, the binding walk, the decl validator, and every printer (diagnostics, c_import, bundle interface) swap the written arguments. The retired spelling with a literal count gets one diagnostic naming the order. Tree rename was one Lexer-accurate pass (40 sites) plus hand fixes inside f-strings; historical docs keep the old spelling as record.

Array-length generics by Vector's mechanism: [T; N] binds N from the argument's length as a TY_CONST_INT substitution ([T; N, N], [T; R, C] via nested nodes, conflict diagnosed); lengths resolve per instantiation from the retained length node in Sema, substitution, and frozen resolvers; [0; C, R] fills likewise. Two probe bugs fell out and are fixed at their roots: type_expr_mentions_type_param ignored array length nodes (so expected-type probes resolved [i32; N] unbound and consumed the length node before inference could bind it), and array_type_len destructively cleared that node under cascade-suppression probes.

Fixtures: behav_d119a1_vector_element_first, behav_d119a1_array_length_generics (total/trace/transpose), err_d119a1_vector_old_spelling, err_d119a1_array_length_conflict. Method generics and zero lengths verified by hand; audit:resolution clean on the fixture. A bracket literal still takes no generic array demand — pre-existing on main, filed as #2379.

Iterate evidence: stage1 runs all touched SIMD behavior files (13) and compile-error files (10) green; census --diff clean. Gate + one battery bless this stack top (487b12d).

…hs are generic parameters

§4.3d (ruled 2026-10-12, #2376): Vector writes its element first like
[T; N]; Mask[N, W] keeps its count first, as the ruling left it. The
internal type (d0 lane, d1 count) is unchanged — every resolver, the
frozen twins, the call-site binding walk, the declaration validator,
and the printers (diagnostics, c_import, bundle interfaces) swap the
two written arguments. The retired spelling with a literal count is
refused by naming the order. One Lexer-accurate pass renamed the tree's
40 unambiguous sites in tests (plus hand fixes inside f-strings, which
lex as one token); comments followed.

Array-length generics by Vector's mechanism: [T; N] binds a generic N
from the argument's array length in bind_type_params_from_type_expr
(nested nodes bind [T; N, N] and [T; R, C], with a conflict diagnostic),
as a TY_CONST_INT substitution. array_type_len and array_fill_count read
that substitution per instantiation and keep the length node in d2 —
each instance writes its own d1, the next re-reads d2; the frozen and
substitution resolvers bind the same way. type_expr_mentions_type_param
now counts a generic length as a mention: without it the expected-type
probe resolved [i32; N] with N unbound (erroring and consuming the
length node) before inference could bind it. A probe that resolves a
generic length under a non-integer substitution (template probe,
cascade suppression) is non-destructive and quiet — the one 'cannot
infer' diagnostic owns the failure.

Tests: behav_d119a1_vector_element_first (dot[N] over Vector[f32, N],
aliases unchanged), behav_d119a1_array_length_generics (total[N],
trace[N], transpose[R, C] incl. [0; C, R]), err fixtures for the retired
spelling and a length conflict. A bracket literal still takes no
generic array demand — pre-existing on main, filed as #2379.
@ehartford
ehartford added this pull request to stack #2381 October 13, 2026 04:16
@ehartford ehartford changed the title d119a1 vector length generics D119 Amendment 1 (#2311): Vector[T, N] element-first + array-length generics Oct 13, 2026
…lling)

The Amendment 1 comment sweep changed bytes in an ABI-defining source;
the convention did not change, so the hash is re-recorded with no
WITH_ABI_VERSION bump. Every .wo rebuilds once.
@ehartford

Copy link
Copy Markdown
Contributor Author

Gate GREEN on 975e66f (seed-driven src/main build :gate, rerun after re-recording docs/with-abi.sha256 for the TypeLayout comment): d119a1-gate2.log: rc=0 green. Battery over this stack top next.

@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on stack top 975e66f (seed-driven, with run tools/battery.w, 2026-10-12):

975e66f6d /Users/eric/.local/with-staging/d119a1
gate rc=0 wall=124s
uat rc=0 wall=29s
battery-checks rc=0 wall=1428s
GREEN
battery: GREEN (975e66f6d); logs in out/battery/

One battery blesses the whole stack (#2378 + #2380).

@ehartford
ehartford marked this pull request as ready for review October 13, 2026 05:08
@ehartford
ehartford merged commit e10eff9 into main Oct 13, 2026
@ehartford
ehartford deleted the d119a1-vector-length-generics branch October 13, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant