Files
sx/examples/1138-diagnostics-inline-for-non-integral-bound.sx
agra 0d29f2c286 docs(spec): split range bounds from counts; pin inline-for range semantics (0083)
specs.md lumped `inline for` / `for` range bounds in with counts (array
dimension, Vector lane count, generic value-param count) under the
count negative-rejection rule. A range bound is a range ENDPOINT, not a
count: negative endpoints are valid and an empty/inverted range runs zero
iterations. The compiler already implements this correctly (Agra ruling:
spec-text bug, no code change).

- specs.md: counts and range bounds are now described separately. Counts
  reject negatives; bounds accept any compile-time integer (negatives
  valid, integral floats fold) but still reject a non-integral float
  because the loop cursor must be an integer.
- examples/0612-comptime-inline-for-range-bounds.sx: `inline for -2..1`
  and `for -2..1` both sum -3; `inline for 0..(-2.0)` runs zero
  iterations (empty range). Runtime/comptime parity asserted.
- examples/1138-diagnostics-inline-for-non-integral-bound.sx: a
  non-integral float bound `inline for 0..4.5` is a clean diagnostic,
  exit 1 (must-be-integer still applies to bounds).

Count consumers (1132/1133/1134/1135) unchanged and green.
2026-06-04 15:17:33 +03:00

15 lines
573 B
Plaintext

// A NON-integral float (`4.5`) as an `inline for` range bound is a hard error:
// the loop cursor must be a compile-time integer, so only an integral float
// (`4.0`, `-2.0`) folds. Clean diagnostic + non-zero exit.
//
// Regression (F0.4 attempt 11, Agra ruling): range bounds are exempt from the
// count negative-rejection (negatives are valid endpoints), but the
// must-be-integer requirement still applies — `4.5` has no integer value.
#import "modules/std.sx";
main :: () {
s := 0;
inline for 0..4.5: (i) { s += i; }
print("unreachable: {}\n", s);
}