31. Build errors (pocket version)

TL;DR (5 lines)

  • Diagnostics point back to a broken contract.
  • A valid and invalid pair is the right teaching unit.
  • Smaller repros are more educational than giant failing files.
  • The first useful question is what contract broke.
  • Actionable fixes start from structure, not from guesswork.

Concrete Problem

Readers often see diagnostics as messages to memorize rather than structured signals tied to a failing contract.

Coherent example

space demo/diagnostics

proc safe_div(total: int, count: int) -> int {
  if count == 0 { give 0 }
  give total
}

Global explanation

A diagnostics chapter should explain the shape of a failure: what contract was expected, which surface broke it, and how to return to a valid program. The message is a pointer back to structure, not an isolated artifact.

Short exercise

Take the invalid example and reduce it until one diagnostic still reproduces the same contract failure.

Next best action

Keep the example small, reproduce it locally, then continue to the full chapter if you need the broader context.