Skip to content

base/ops.t27: compile again (i8 index, tuple literal) and fix the 7 tests that then fail (#8095 closure hub) #8239

Description

@gHashTag

Problem

specs/base/ops.t27 has never compiled. Its three seals record blocked: spec.zig:31:46: error: expected type 'usize', found 'i8'. It imports nothing, and 13 specs import it, so t27c frontier rebuilds all 13 on closure (epic #8095). The re-mint in #8232 skipped it, because only green specs were resealed.

There are two compile defects, both fixable in the spec alone:

  1. Lines 55, 62 and 70. const idx = (@intFromEnum(a) + 1) * 3 + (@intFromEnum(b) + 1); is an i8, because Trit is enum(i8), and it indexes a table. Fix: const idx: usize = @as(usize, @intCast((@intFromEnum(a) + 1) * 3 + (@intFromEnum(b) + 1)));
  2. Ten test sites (lines 361, 401, 448, 486, 499, 584, 619, 644, 662 and 709). const trits = [_]Trit{ .neg, .zero, .pos }; lowers to an anonymous tuple, and for (trits) then fails with "tuple field index must be comptime-known". Fix: const trits: [3]Trit = [3]Trit{ .neg, .zero, .pos };

With both fixes applied, measured 2026-10-09 with t27c 0.5.2 on master e3b8c51, the spec compiles and 7 of 87 tests fail. These are real failures that the compile error had hidden:

  • test_trit_add_with_carry_positive_overflow
  • test_trit_add_with_carry_negative_overflow
  • test_trit_add_with_carry_propagation
  • test_trit_min_max_antisymmetric
  • test_trit_multiply_with_carry_basic
  • test_trit_multiply_with_carry_with_carry
  • test_trit_cond_swap_condition_true

For each one, decide whether the function or the test is wrong, using balanced-ternary arithmetic as the oracle: a + b = sum + 3 * carry, with every digit in {-1, 0, 1}. Fix the side that is wrong. Do not weaken a test to make it pass.

Acceptance criteria

  • t27c test-report specs/base/ops.t27 prints FAIL 0 and vacuous passes 0 of 87 or more
  • each of the 7 tests above still asserts the balanced-ternary identity it names, checked against hand-computed vectors written in the test
  • t27c seal specs/base/ops.t27 --save succeeds without --force, and its seals carry "seal_schema": 2

Boundary

specs/base/ops.t27

User Scenarios

  • Given the spec specs/base/ops.t27 fails to compile due to an i8 index used where usize is expected and tuple literals used where arrays are required, When the two compile defects are fixed in the spec source, Then t27c test-report specs/base/ops.t27 compiles the spec and runs all 87 tests.
  • Given the spec compiles after the two fixes, When the 7 failing tests are corrected by fixing the side (function or test) that violates balanced-ternary arithmetic, Then t27c test-report specs/base/ops.t27 prints FAIL 0 and each of the 7 tests still asserts the balanced-ternary identity it names against hand-computed vectors.

Requirements

FR-001: The spec specs/base/ops.t27 MUST compile without errors after applying the two source fixes: casting the table index to usize at lines 55, 62, 70 and changing the ten tuple literals to typed array literals [3]Trit{…}.
FR-002: Each of the 7 currently failing tests MUST be fixed by correcting either the function implementation or the test expectation so that the balanced-ternary identity a + b = sum + 3 * carry (with digits in {-1,0,1}) holds for the hand-computed vectors written in the test.
FR-003: No test MUST be weakened or removed to achieve a pass; the test must continue to assert the arithmetic identity it is named for.
FR-004: t27c seal specs/base/ops.t27 --save MUST succeed without --force and the written seals MUST carry "seal_schema": 2.

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