feat(t27b): slices []T -- params, a[i..j], a[i..], .len, checked index, for - #6249
Merged
Merged
Conversation
…x, for (Closes #6248) []T and []const T lower to a 16-byte (ptr, len) header in memory, an aggregate passed by reference like a struct; []const u8 stays str. Zig's coercions: *[N]T -> []T, *const [N]T and []T -> []const T, and &[_]T{...} -> []const T. s[i] reads the header once and checks the index against its length (Bounds; traps "index out of bounds"); str indexing is now supported. x[i..j] and x[i..] of an array, pointer to array, slice or str check i <= j <= len (constants at compile time, otherwise a trap). .len is a read-only field; for (s) |x| walks the elements. Only lowering changes; the IR, interpreter and AArch64 back end are untouched. t27b corpus specs (native macOS arm64): 161 -> 162 pass (931 -> 938 tests), 278 -> 278 pass_vacuous, 2 -> 2 fail (same files), 764 -> 763 rejected, 0 mismatch. `type []T` was the first blocker of 136 files and is now 0; those files stop on the next blocker (f32, BenchBlock, f64, ?T ...). The reference writes x[i..] as x[i] and &[_]T{} as &.{ _ }. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 4, 2026
This was referenced Oct 4, 2026
This was referenced Oct 4, 2026
gHashTag
added a commit
that referenced
this pull request
Oct 4, 2026
…going (Closes #6244) A non-required check red on the PR was judged against master's last verdict even when a newer master run of it was still in progress, so a stale SUCCESS blocked #6249. fold_master now reports PENDING for a run still going on a newer commit, and check_effect (steward.t27) makes such a red check WAIT. 81 tests on t27b and the t27c lab; gen-c byte-equal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks
Contributor
This was referenced Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6248. Refs #6063. Stacked on #6247 (claude/t27b-fixed-arrays).
What
[]Tand[]const Tlower to a 16-byte (ptr, len) header, passed by reference like a struct.[]const u8staysstr.*[N]Tbecomes[]T.*const [N]Tand[]Tbecome[]const T.&[_]T{...}becomes[]const T.s[i]reads the header once, then bounds-checks the index. Out of range trapsindex out of bounds.strindexing is now supported.x[i..j]andx[i..]work on an array, a pointer to an array, a slice or a str. Each checksi <= j <= len: constants at compile time, runtime values with a trap..lenis read-only.for (s) |x|walks a slice or a str.Corpus (
t27b corpus specs, macOS arm64)type []Twas the first blocker in 136 files (237 files counting every blocker) and is now in 0.validation_engine.t27, which the reference also passes (7/7).Reference bugs found
The reference
t27c genwritesx[i..]asx[i]and&[_]T{}as&.{ _ }, so its Zig fails on both.Tests
cli/t27b/tests/source.rsadds these tests:cargo test -p t27bpasses.🤖 Generated with Claude Code