Files
sx/tests/expected/163-pack-runtime-index.txt
agra 82bdcd634a lang F1 2.6: pack-index edge cases (runtime-index error, comptime OOB)
Per locked Decision 1 a pack is comptime-only with no runtime value, so xs[i]
is valid only for a comptime index. lowerIndexExpr now emits a clear error
("pack <p> must be indexed by a compile-time constant ...") for a runtime
index, instead of the confusing "unresolved <p>" the slice-index fall-through
produced. diagPackIndexOOB switched from int-literal-only to comptimeIndexOf so
an inline-for cursor that goes out of bounds is also caught.

Repurposed examples/163-pack-runtime-index.sx (was aspirational: expected
runtime indexing to materialise a []Any slice and print 4, contradicting
Decision 1) into the runtime-index error test. Comptime + OOB cases already
covered by examples/199/200/161. 236 examples + unit green.
2026-05-30 01:30:11 +03:00

6 lines
305 B
Plaintext

error: pack 'args' must be indexed by a compile-time constant — a pack is comptime-only and has no runtime value
--> /Users/agra/projects/sx/examples/163-pack-runtime-index.sx:18:24
|
18 | x : Any = args[i]; // ERROR: runtime index into a comptime-only pack
| ^