You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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 #1211
$ 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)importBase
type LisData:
LNil{}
LCons{h: U32, t: L}
typeBxisType:
MkBx{f: U32->U32}
defk(a: Bx, b: L) ->U32:
matcha:
caseMkBx{f}:
matchb:
caseLNil{}:
0caseLCons{h, t}:
c= {MkBx{f} : Bx}
k(c, t)
# ---- tyerr.bend ----defmain() ->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_verdict writes FAIL (main.ts:714-716 for the unsafe/foreign gate, :720 for the kernel), returns 1,
and its caller sets process.exitCode at :301;
cli_file's catch writes at :318 and sets process.exitCode = 1 at :319;
cli_checkup writes exit N to stdout at :345, then process.exit(1) at :350;
cli_fail writes, then process.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 | ….
Activity
A closed pipe reader does not turn a CLI failure into success (#1211) (…