A failing --verdict, --check-only, run or --checkup exits 0 if its output goes to a reader that has already exited (cli_say's EPIPE branch calls process.exit(0)); pipefail doesn't catch it
What you did
bend fail.bend --verdict 2>&1 | true
What happened
$ bend fail.bend --verdict # alone: MISMATCH on stderr, exit 1
$ bend fail.bend --verdict 2>&1 | true # PIPESTATUS=0 0
$ bend fail.bend --verdict 2>&1 | head -n 0 # PIPESTATUS=0 0
$ ( set -o pipefail; bend fail.bend --verdict 2>&1 | true; echo $? )
0
$ bend tyerr.bend --check-only 2>&1 | true # PIPESTATUS=0 0 (alone: SOME PROOFS FAIL, exit 1)
$ bend tyerr.bend 2>&1 | true # a plain run: PIPESTATUS=0 0 (alone: exit 1)
$ bend unsafe.bend --verdict 2>&1 | true # PIPESTATUS=0 0 (alone: "2 defs rely on unsafe or foreign code", exit 1)
$ bend --checkup chk.bend 2>/dev/null | head -1 # "--- tyerr.bend ---", PIPESTATUS=0 0 (alone: exit 1)
Controls: bend ok.bend --verdict | true stays 0 (correct); bend fail.bend --verdict | head -1 gives 1.The file
# fail.bend: bend2 accepts it, the kernel rejects it (In k: affine live code, calls that descend)
import Base
type L is Data:
LNil{}
LCons{h: U32, t: L}
type Bx is Type:
MkBx{f: U32 -> U32}
def k(a: Bx, b: L) -> U32:
match a:
case MkBx{f}:
match b:
case LNil{}:
0
case LCons{h, t}:
c = {MkBx{f} : Bx}
k(c, t)
# ---- tyerr.bend ----
def main() -> Nat: True
# ---- chk.bend (for --checkup): imports tyerr.bend and an ok.bend ----cli_say
(main.ts#L778-L787)
calls process.exit(0) on EPIPE. Every failure path writes its text before setting the failure status:
cli_verdictwrites FAIL (main.ts:714-716 for the unsafe/foreign gate, :720 for the kernel), returns 1, and its caller setsprocess.exitCodeat :301;cli_file's catch writes at :318 and setsprocess.exitCode = 1at :319;cli_checkupwritesexit Nto stdout at :345, thenprocess.exit(1)at :350;cli_failwrites, thenprocess.exit(1)(:789-792).
So if the reader is gone before bend's first write, every failure exits 0. set -o pipefail can't help,
because bend itself returns 0. The direction is one-way (failure → 0, never the reverse), and with
| true no FAIL text is shown either.
Suggested fix (tested on scratch copies). Set the status before each failure write (main.ts:714,
720, 318-319, cli_fail, --checkup's exit N), and in the EPIPE branch exit with that status:
process.exit(process.exitCode === undefined ? 0 : Number(process.exitCode)). That fixes every case
above. One gap remains: --checkup chk.bend | true exits before the failing import is even reached. A
complete fix exits non-zero on EPIPE while the outcome is still unknown, or keeps checking without
writing and exits with the real status.
Not a soundness issue: the kernel's answer is unchanged and no PASS text is printed. It matters to any
CI gate of the form bend f.bend --verdict 2>&1 | ….
bend --version
bend 2.0.32
uname -sm
Linux x86_64
clang --version (the first line)
No response
Source: HigherOrderCO/Bend