#1212·Bend

--verdict: safe.ts's group_of picks a group by a def's first later-filled name, not by membership — a dead forward reference to a law crashes -o/--verdict, emits a non-member selector, or (with a name_tt collision) PASSes a book computing a different value

Author: VacrinCreated Sep 30, 2026Updated Sep 30, 2026
Labelsbug

What you did

bend fb3.bend; bend fb3.bend --verdict; then kernel oracles on bend fb3.bend -o fb3.bendtt (and --verdict on g4.bend, g2.bend)

What happened

fb3.bend (with a-b.bend beside it):
$ bend fb3.bend --check-only      ALL PROOFS CHECK
$ bend fb3.bend                   False{}
$ bend fb3.bend -o fb3.bendtt     exit 0, no out-of-scope lines
$ bend fb3.bend --verdict         ALL PROOFS CHECK
Kernel oracles appended to fb3.bendtt:
  ora : {main == (.True,  ()) : Bool} = {==}   -> ALL PROOFS CHECK
  ora : {main == (.False, ()) : Bool} = {==}   -> In ora: expected: main / observed: (.False, ())

g4.bend:
$ bend g4.bend --check-only       ALL PROOFS CHECK
$ bend g4.bend --verdict          TypeError: null is not an object (evaluating 'g.k')   (exit 1, no FAIL header)
$ bend g4.bend -o g4.bendtt       the same TypeError; no file written

g2.bend:
$ bend g2.bend --verdict          SOME PROOFS FAIL (MISMATCH)
  -o emits  use : ∀x0 : Nat -> Nat = λx0 => {(L.group x0 (.d, (.L, ()))) : Nat}
  kernel:   In use: a label of <L, h>

The file

python
# ---- a-b.bend ----
def ign(-b: Bool, r: Bool) -> Bool:
  r

law L:
  for n: Nat
  Bool

def M(n: Nat) -> Bool:
  ign(L(n), True{})

# ---- fb3.bend ----
import Base
import ./a-b.bend as AB

def a_2d_b.M(n: Nat) -> Bool:
  AB.ign(AB.L(n), False{})

def AB.L(n):
  match n:
    case Zero{}:
      True{}
    case Succ{p}:
      AB.M(p)

def main() -> Bool:
  a_2d_b.M(Zero{})

# ---- g4.bend ----
import Base
def keep(-p: Nat, x: Nat) -> Nat:
  x
law L:
  for n: Nat
  Nat
law L2:
  for n: Nat
  Nat
def h(n: Nat) -> Nat:
  keep(L(n), n)
def L(n):
  match n:
    case Zero{}:
      keep(L2(0n), 0n)
    case Succ{m}:
      h(m)
def L2(n):
  0n

How a group forms. later(k) (safe.ts#L942-L945) lists the defs k's body names that are filled after k. It reads refs (L1074-1089), which walks every field except s, v and T, so a reference in an erased argument counts. group_of(k) (L947-953) is group_new(later(k)[0] ?? k): the group led by k's first later-filled name, whether or not k is in it. A live forward call to an unfilled law is rejected by bend2, but a dead one (keep(L(n), n) with keep(-p: Nat, x: Nat)) is not.

Three faces from that.

  • Crash (g4). A call to the member h queues the item '\t' + L; item_emit (L272-274) rebuilds the group with group_of(e, L) — a different computation — and L's own dead reference to L2 gives group_new(L2), which is null because nothing names L2 back. group_emit dereferences g.k (L1014). A TypeError isn't a Scope_Error, so it escapes to main.ts as a raw trace.
  • Non-member selector (g2). args (L918-921) routes a call through group_call whenever group_of(k) is non-null, without checking membership. d has a dead reference to L, so its call goes out as L.group with selector .d, which isn't in the enum <L, h>.
  • Wrong program, PASS (fb3). Same misroute, but the non-member's name a_2d_b.M collides under name_tt with the module's member a-b.M (#1131), so the label lands inside the enum <a_2d_b.L, a_2d_b.M> and the kernel accepts. main is wired to the module's M (True); the local def the source names is emitted as a_2d_b.M_ and nothing references it.

Not a proof of Empty: bend2 checks the source at the source's types and the misroute only rewrites safe.ts's copy, so whichever side reads a type as Empty rejects. But a --verdict PASS here no longer attests to the source book.

  1. item_emit (L274): rebuild the group from its lead, group_emit(e, group_new(e, k.slice(1)) as Group, cols, n).
  2. args (L919): if (g !== null && g.ms.includes(k as Name)). With both, g2 and g4 PASS and use becomes λx0 => (d x0).
  3. Alternatively, have refs/later count only live positions, so a dead reference never forms a group (not tested).

Separately, C3 on #1131 (labels aren't made unique the way def names are) is what turns the misroute into a silent PASS.

bend --version

bend 2.0.34

uname -sm

Linux x86_64

clang --version (the first line)

No response