A goal or error that mentions a self-referential `@unsafe` placeholder never prints: the checker unfolds it forever
What you did
bend stub_loop.bend --check-only
What happened
No output; it runs until killed (killed after 30 s here). The control file below differs only in giving two a real proof. It prints the hole's goal in about 1 s:
SOME PROOFS FAIL
Error:
- expected : {x == y : P(2n)}
- observed : ?todoThe file
import Base
law two:
{Nat.add(1n,1n) == 2n : Nat}
# a placeholder for a lemma proved elsewhere, as parallel provers use
@unsafe def two(): two
def moved(P: Nat -> Type, x: P(Nat.add(1n,1n))) -> P(2n):
%two : P(_)
x
def goal(P: Nat -> Type, x: P(Nat.add(1n,1n)), y: P(2n)) -> {moved(P,x) == y : P(2n)}:
?todoControl: the same file with def two() -> {Nat.add(1n,1n) == 2n : Nat}: {==} and %two() : P(_).
Why
To print a goal or an error, expr_show strongly normalises the term. The goal contains moved(P,x), whose rewrite needs its evidence two in weak head normal form. two's body is two, so unfolding never ends. Correct proofs that use the placeholder check instantly; only printing loops. A "cannot infer" error on a let whose value is such a rewrite hangs the same way.
Impact
We prove large kits in parallel, with one @unsafe placeholder per lemma proved in another file (the pattern @unsafe def K.lemma(): K.lemma). Any small mistake near a borrowed lemma hangs instead of reporting, so provers never see their error. Across one run, 147 checks hung until a timeout killed them.
Possible fix
Treat a placeholder whose body is only a reference to itself as stuck, i.e. don't unfold it in term_wnf. It has no computational content, so no correct program changes. We prototyped this on 2.0.16: goals and errors then print in about 0.15 s, and the 243 files under tests/check and tests/eval give the same output. Bounding the expansion while printing (see #1041) would also cover it.
Related: #1041 (an error expanded before printing grows as 2^n), #1202.
bend --version
bend 2.0.34
uname -sm
Darwin arm64
clang --version (the first line)
Apple clang version 21.0.0 (clang-2100.3.34.2)
Source: HigherOrderCO/Bend