Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · XO0903

Docs

XO0903: an I/O error turned into a default

warning · reported by the vet

A filesystem, network, or process call can fail for reasons other than a missing file: no file descriptors or memory left, an I/O error, an interrupted read. Turning every error into a default (os.fs.read_dir(d).ok() ?? []) makes such a failure look like an empty directory or an empty file, so the program answers from part of its input: a directory walk that drops a subtree, a hash of a partial tree, a file rewritten from empty text. xo itself had these bugs (2026-10-21). Match the result instead, keep the default for the errors it is right for, and return or report the rest. When the default is right for every error (a hint, a cache miss that is rebuilt), say so on the line or the line above: // xo:allow XO0903 <reason>; a comment without a reason does not count.

Example

for e in os.fs.read_dir(d).ok() ?? [] { ... }

Fix

match the result: `Ok(es) => es`, `Err(NotFound(_)) => []` for a missing directory, `Err(e) => return Err(e)` for the rest; or `// xo:allow XO0903 <why every error may be the default>`

Run xo explain XO0903 for this text in a terminal, or see section 10.6 of the specification.