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.
This commit is contained in:
@@ -1 +1 @@
|
||||
0
|
||||
1
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
4
|
||||
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
|
||||
| ^
|
||||
|
||||
Reference in New Issue
Block a user