println, print, eprintln and eprint Throw io::IoError and Never PanicStatus: Accepted
Date: November 7, 2026 (owner’s decision)
Answers: #1355 (what a failed write does under ADR-async-v7 D35)
Related: Part I 7.1 (a function without throws cannot fail); Part III 17.1
(writing output); ADR-async-v7 D35 (a task’s crash is a
failure only where the task can panic)
A write to standard output or standard error can fail: the reader closed the
pipe (prog | head), the disk behind a redirect is full, the descriptor was
closed. Until now the four print functions lowered to Rust’s println!, which
panics then. Under D35 that made every function that prints able to panic, so
every task that prints would have to handle task::Crashed, a failure that
names the wrong thing. Part III 17.1 said nothing about it.
io::IoError. The print functions are calls that can fail, as
every other write is.io::IoError when the write fails, and never panic.println(text), print(text), eprintln(text) and
eprint(text) report a failed write as io::IoError, the error every other
write in std throws. Their ledger entries say throws = ["io::IoError"] and
panics = false.
A function that prints can fail, so
it says throws or handles the failure with catch (Part I 7.1), main
included. An io::IoError that leaves main ends the program with exit
status 1 and its message on standard error, as every other error does; a
failed write to standard error itself is not written again.
nikaia migrate print-throws PATH... adds
throws to every function whose body can now fail only because it prints
(and to its callers, as far as the new failure reaches), and leaves a function
that already handles failures alone. The repository’s programs, tests,
examples, guide and website are moved with it in the commit that builds D1.
io::IoError of its call, handled where its value is
first needed.throws. That is the cost the owner accepted for a
failure that is real.