Skip to content

t27c gen: open-ended slice a[2..] is emitted as a[2] #8200

Closed

Description

@github-actions

Re-filed from #6371. An attempt claimed that issue on 2026-10-05 and left an empty branch, and a dispatch row that has spent its retry ceiling keeps its issue for good - so no bee could take it again, however much the brief improved. The work below is carried over unchanged.


Problem

t27c gen (Zig) silently drops the range of an open-ended slice: a[2..] comes out as a[2], which is an element, not a slice. The reference path then reports a type error, or worse, a different value, while the spec is correct.

Repro (t27c 0.4.0 at /tmp/t27shared, master 0757c2f):

module SliceProbe;
pub fn tail_len(a: [4]u8) -> u32 {
    var t : []const u8 = a[2..];
    return t.len as u32;
}

t27c gen s.t27 line 19: var t: []const u8 = a[2];

Goal

a[lo..] is emitted as a[lo..] (and a[lo..hi] keeps both bounds), or the parser refuses the form with a named error. It must never drop the range silently.

Scope

bootstrap/src/compiler.rs slice parsing/emission; a test spec with an open-ended slice.

Acceptance

The repro's generated Zig contains a[2..], and a test asserting tail_len == 2 passes under t27c test-report.

Found by the t27b steward loop (Refs #6063); t27b counts specs using this form as reference failures.

Boundary

  • bootstrap/src/compiler.rs

User Scenarios

  • Given a spec with an open-ended slice a[2..] assigned to a slice-typed variable, when t27c gen emits Zig, then the generated code contains a[2..] (not a[2]) and t27c test-report passes with the expected length value.

Requirements

  • FR-001: The compiler MUST emit open-ended slice syntax a[lo..] in generated Zig exactly as written in the spec.
  • FR-002: The compiler MUST NOT silently drop the range operator .. when the upper bound is omitted.
  • FR-003: If the syntax cannot be emitted correctly, the compiler MUST reject the spec with a named parse or emit error rather than producing incorrect code.

The instruments

Every one of these reads and prints; none of them writes. Run them from the repository root, with <spec> replaced by the file in ## Boundary:

.t27 is not Rust and not Zig, and a bee fluent in either writes one by
accident. Measured 2026-09-20: a bee filled eight bodies in
specs/file/watcher.t27 with return Ok(());, Err(FileError::WatcherNotFound)
and for i in 0..watchers.length. The parse ratchet refused the whole file --
Unexpected token in expression: RParen, line 123 -- and a spec that does not
parse generates nothing, so every test it already carried stopped running.

At the top level the parser accepts exactly these eight forms, with an optional
pub, and no others:

const   var   fn   enum   struct   test   invariant   bench

There is no trait, no impl, no type X = ..., no generics, no macro. What
a bee reaches for from another language, and what happens:

  • Rust's result sugar (Ok(()), Err(E::V), ?) is not a construct here.
  • Rust macros (println!, format!, vec!) are not constructs here.
  • A range loop (for i in 0..n) is Rust and Zig, not this language.
  • Zig builtins (catch unreachable, @intCast, @constCast) are not constructs here.
  • Cross-module reuse (use other::fn;) parses and then generates a comment and an unqualified call, so the Zig fails with use of undeclared identifier (use a::b; generates no import, so no spec can reuse a function from another spec #4298). It does not work yet.

t27c parse <spec> answers in one line whether what you wrote is the language.
Run it before you report, every time.

  • t27c spec-status <spec> - the compiler's one-word verdict: IMPLEMENTED, PARTIAL, UNWRITTEN, NOPARSE, NOFN. Exit code is 0 whatever it says, so read the word.
  • t27c symbols <spec> - every name the file declares, with its kind. Answers "does this already exist here?" before you add it.
  • t27c outline <spec> - per function: its locals, what it calls, what it returns. The contract you are implementing against.
  • t27c coverage <spec> - which functions have a test and which do not. The issue asks for tests; this is how you check you wrote them.
  • t27c lint <spec> - style and shape warnings. It OVER-REPORTS has no test or invariant: measured 2026-09-20 over 60 specs it printed 677 of those where coverage found 190 untested functions, disagreeing on 59 of the 60 - it warns about bit_to_trit_pair in specs/base/ternary_encoding.t27, which test bit_to_trit_pair_zero calls on line 249. Read it as a hint; coverage is the answer.
  • t27c typecheck <spec> - types, before generation. Prints Typecheck OK (0 errors, 0 warnings) or the errors.
  • t27c test-report <spec> - builds this spec and runs its own tests, which is what the oracle does. BLOCKED means the generated Zig does not compile, with the error beside it.
  • python3 tools/dupe_scan.py --name <function> - where that function already lives, if it does. 576 of 4021 bodies here are byte-identical copies.

The rest of the toolbelt is in docs/BEE_TOOLBELT.md.

Activity

  1. gHashTag commented on Oct 18, 2026

    @gHashTag
    Owner

    Second repro, found while building specs/t27f/reel_particles.t27 (#10308): std.debug.print("{s}", .{row[0..]}) on a [12]u8 generated .{ row[0] }, and zig 0.16 rejects that with "invalid format string 's' for type 'u8'". The fix is in #10319: gen-zig ExprIndex now lowers both slice and slice_open to Zig slices. Conformance spec: specs/compiler/zig_open_slice.t27, 3 tests passing on the Railway lab.

  2. added a commit that references this issue on Oct 18, 2026
    7912660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions