Files
sx/examples/0147-types-zero-count-context.sx
agra c01ece5483 docs(spec): make the count zero-rule context-dependent per consumer (0083)
The count description claimed every count must be "positive integral",
which is wrong: zero is context-dependent. Verified at HEAD — an array
dimension (`[0]s64`) and a generic value-param count (`Box(0)`, $N:u32)
both accept zero as a length-0 instantiation, while a `Vector` lane
count stays strictly positive (`Vector(0,f32)` rejected). Negatives are
rejected for array dims and unsigned value-params, but a signed
value-param accepts a negative; only the integral requirement (folds
4.0, rejects 4.5) is common to all three.

Split the count paragraph into per-consumer bullets stating the exact
range each accepts. Range-bound paragraph unchanged. Pin the zero
contrast with examples 0147 (array-dim + value-param zero accepted) and
1505 (Vector zero-lane rejected). No compiler-code change.
2026-06-04 15:32:48 +03:00

20 lines
739 B
Plaintext

// Zero is a context-dependent count. An array dimension and a generic
// value-param count both ACCEPT zero — `[0]T` is a valid empty (zero-length)
// array, and `Box(0)` is a length-0 instantiation. (A `Vector` lane count
// rejects zero — see 1505.) This pins the zero-accepting half of the
// context-dependent count rule documented in specs.md (Array Types).
//
// Regression (F0.4 attempt 12): the spec previously claimed every count must be
// "positive integral", which wrongly implied `[0]T` / `Box(0)` are illegal.
#import "modules/std.sx";
Box :: struct($N: u32) { items: [N]s64; }
main :: () {
a : [0]s64 = ---;
print("array_dim={}\n", a.len);
b : Box(0) = ---;
print("value_param={}\n", b.items.len);
}