Skip to content

t27b: an anytype parameter the body reads with @TypeOf -- one instance per argument type (queen-public-agents.t27) #8713

Closed

Description

@gHashTag

Part of epic #8326 (coverage, see #6063). This is the last `type anytype` row in docs/reports/t27b_expectations.json.

Problem

In `specs/port/browseros/trios/agent-server/apps/server/src/api/routes/queen-public-agents.t27`, `heartbeatTime(value: anytype)` reads its parameter. It branches on `if (@typeof(value) == i64)` and returns `value` inside that branch. The tests call it with an i64, a string and null.

The reference passes 9/9. Zig compiles the function once per argument type, folds `@TypeOf(value) == i64` at compile time, and never type-checks a branch whose condition is false. The spec is correct; this is not a spec defect.

#8028 (any_param_plan) covers only an anytype parameter the body never reads, and any_param_plan.t27 lists this case as not covered.

Minimal repro

The reference gives 1/1 with 3 asserts. t27b refuses with `type anytype at line 3`.

module AnyTypeOfRepro;

fn h(v: anytype) -> ?i64 {
    if (@TypeOf(v) == i64) {
        return v;
    }
    return null;
}

test reads_by_type {
    assert(h(@as(i64, 5)) == 5);
    assert(h(null) == null);
    assert(h("x") == null);
}

What t27b needs

  1. One instance of the function per distinct argument type at its call sites (monomorphization), named deterministically.
  2. `@TypeOf(param) == T` folded per instance at compile time.
  3. A branch whose condition folds to false is skipped, not lowered, as Zig skips analysing it.

Each decision belongs in a .t27 plan (any_param_plan), with net <= 0 hand-written lines (#8236). With `heartbeatTime` and its 4 tests removed, t27b already passes the other 5 tests (9 asserts), so this is the spec's only blocker.

Acceptance

  • The repro passes `t27b test --check`, as a conformance spec under specs/tri/t27b/conformance/.
  • queen-public-agents.t27 passes `t27b test --check` with runtime asserts, and its ledger row is `pass`.

User Scenarios

  • Given a function with an anytype parameter that is read via @TypeOf and branched on (e.g., if (@TypeOf(value) == i64)), when the function is called with multiple distinct argument types (i64, string, null), then t27b compiles one instance per argument type, folds @TypeOf at compile time, skips false branches, and all assertions pass.

Requirements

  • FR-001: t27b MUST monomorphize functions with anytype parameters that are read via @TypeOf, creating one instance per distinct argument type at call sites with deterministic names.
  • FR-002: t27b MUST fold @TypeOf(param) == T at compile time per instance.
  • FR-003: t27b MUST skip lowering of branches whose condition folds to false, not type-checking them.

Boundary

  • specs/port/browseros/trios/agent-server/apps/server/src/api/routes/queen-public-agents.t27
  • docs/reports/t27b_expectations.json

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions