Skip to content

Non-zero exit when the checker reports unsafe or foreign dependencies #966

Closed as not planned

Description

@noah-emp

Behavior

When a book type-checks but relies on @unsafe or foreign defs, bend prints:

All terms check, but N defs rely on unsafe or foreign code:
- …

and exits 0.

TODOs and type errors exit 1. The unsafe/foreign path does not.

Related history: #776 asked for a non-zero exit when @unsafe is in the import graph; it was closed after requiring PROOF.bend to import ./LAWS.bend (2.0.8). The exit-0-on-unsafe half was not changed. #805 / #874 improved disclosure / counting; they did not make the status non-zero.

Minimal example

# unsafe.bend
import Base

@unsafe def contradiction() -> {0n == 1n : Nat}:
  contradiction()
# LAWS.bend
import Base
import ./unsafe.bend as U

law falso:
  {0n == 1n : Nat}
# PROOF.bend
import Base
import ./LAWS.bend as Laws
import ./unsafe.bend as U

def Laws.falso():
  U.contradiction()
bend PROOF.bend; echo exit=$?
bend PROOF.bend --check-only; echo exit=$?

Observed on bend 2.0.23:

All terms check, but 1 def relies on unsafe or foreign code:
- LAWS.falso
exit=0

Contrast: a bare TODO law exits 1 (Error: N TODO found.).

Request

Prefer one of:

  1. Exit non-zero (e.g. 1) whenever the unsafe/foreign dependency verdict is printed, or
  2. Keep exit 0 only behind an explicit opt-in (e.g. --allow-unsafe), defaulting to non-zero, or
  3. A dedicated flag such as --strict-proof that exits non-zero if any listed unsafe/foreign def remains.

Goal: process exit status matches the checker’s own distinction between a fully checked book and one that still depends on unsafe or foreign defs.

Activity

  1. VictorTaelin commented on Sep 27, 2026

    @VictorTaelin
    Contributor

    This is a documented design choice. WONTFIX.txt, DESIGN: "@unsafe programs check and exit 0 (#776, #805). The checker prints 'All terms check, but N defs rely on unsafe or foreign code:', lists them, and exits 0. @unsafe is a choice the author made in the source; read the note, not the exit code." A --strict-proof or --allow-unsafe flag is the same exit-code request behind a flag. A CI can grep the note.

    Note: an AI wrote this reply after I made the decision. If anything here is wrong, reply and I will review it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions