Repository navigation
t27b: an array literal of strings for a slice field or a returned slice (wrapup-auto) #7833
Copy link
Copy link
Closed
Labels
Description
Part of #6063 (t27b coverage), item C10 of #6488. Follows #7680, #7470 and #7765.
Blocked spec
specs/automation/wrapup-auto.t27 passes the reference (1/1, since #7745). t27b refuses it with ExprArrayLiteral(to slice field) (an array literal whose elements hold a str, for a slice (a t27b static cannot hold a string's address)) at line 44: files_modified: ["specs/automation/wrapup-auto.t27"], a [str] field of a named struct literal.
#7470's description parked this shape until its logic could be written in t27.
What the reference does
t27c prints @constCast(&[_][]const u8{ "specs/automation/wrapup-auto.t27" }), the same form as for scalar elements (slice_lit_plan.t27). The array is a comptime constant of slices that point at string literals:
- reading it is defined;
- writing it is undefined behaviour, which t27b: a write through an array literal printed @constCast(&[_]E{ ... }) is undefined behaviour in Zig; refuse it by name instead of encoding x86_64 Debug's result #7765 refuses by name.
The step
- The plan. In
specs/tri/t27b/slice_lit_plan.t27, elements that hold astrbecome STATIC like any other constant elements, and the refusal is dropped. - Where the object is written. A string's address is not known before the program runs, so a new answer,
written_at_entry, says the object is written at the start of every test, invariant and bench. That is t27b: module vars that hold a string or start undefined (Closes #7448) #7470's mechanism for module vars that hold a string. - The write check. t27b: a write through an array literal printed @constCast(&[_]E{ ... }) is undefined behaviour in Zig; refuse it by name instead of encoding x86_64 Debug's result #7765's check covers the new statics as it covers any STATIC.
- The conformance spec comes first:
specs/tri/t27b/conformance/string_slice_literal.t27.
User Scenarios
- Given the conformance spec
specs/tri/t27b/conformance/string_slice_literal.t27exists andspecs/tri/t27b/slice_lit_plan.t27allows string elements as STATIC, when t27b compilesspecs/automation/wrapup-auto.t27, then it succeeds withoutExprArrayLiteral(to slice field)refusal. - Given a struct literal with a
[str]field initialized from an array literal of string literals, when t27b emits the backend representation, then the array becomes a comptime constant of slices pointing at string literals withwritten_at_entrysemantics. - Given the write check from t27b: a write through an array literal printed @constCast(&[_]E{ ... }) is undefined behaviour in Zig; refuse it by name instead of encoding x86_64 Debug's result #7765, when a STATIC array of string slices is declared, then the check covers it and refuses writes as it does for any STATIC.
Requirements
- FR-001: The conformance spec
specs/tri/t27b/conformance/string_slice_literal.t27MUST be created and define the expected behavior for array literals of strings assigned to slice fields. - FR-002:
specs/tri/t27b/slice_lit_plan.t27MUST be updated so that elements holding astrbecome STATIC like other constant elements, and the refusal forExprArrayLiteral(to slice field)is dropped. - FR-003: The t27b compiler MUST implement
written_at_entrysemantics for module variables that hold string slices, writing the object at the start of every test, invariant, and bench. - FR-004: The write check from t27b: a write through an array literal printed @constCast(&[_]E{ ... }) is undefined behaviour in Zig; refuse it by name instead of encoding x86_64 Debug's result #7765 MUST cover the new STATIC arrays of string slices and refuse writes to them.
- FR-005:
specs/automation/wrapup-auto.t27MUST compile successfully with t27b after the changes.
Success Criteria
t27b specs/tri/t27b/conformance/string_slice_literal.t27exits 0t27b specs/tri/t27b/slice_lit_plan.t27exits 0t27b specs/automation/wrapup-auto.t27exits 0- 3 tests in the conformance suite for string slice literals pass
Boundary
- specs/tri/t27b/conformance/string_slice_literal.t27
- specs/tri/t27b/slice_lit_plan.t27
- specs/automation/wrapup-auto.t27
- scripts/tri_loop/t27b.py
Reactions are currently unavailable
Activity
gHashTag commentedon Oct 9, 2026
#8174 picks up the lane branch
t27b-string-slice(f7abed3). It merges current master in and fits the branch to #7765's write check. It closes this issue and its duplicate, #8091.t27b string slice: set the AGENTS.md debt line and the ledger back to…
t27b string slice: re-apply the ledger rows and the AGENTS.md debt li…
t27b: an array literal of strings for a slice field or a returned sli…