Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Diagnostics

A compiler diagnostic names its phase, the file, and a line and column. It quotes the source it is about. A syntax error that runs to the end of the file, such as an unterminated string, quotes its first line. A diagnostic with no extent names no place.

The phases run in this order, and a phase that reports anything stops the later ones:

PhaseWhat it refuses
parseA token stream that is not a program
resolveA name that does not denote, or a cite that collides
traitAn impl that does not match its spec, or that overlaps another
typeA term whose type does not meet its port
polarityA value or continuation used at the wrong polarity
exhaustivenessAn of or mu that misses a shape, repeats one, or overlaps
effectAn effect the row does not allow, or a handler that does not cover it
loweringA surface form the core cannot express

Within one phase, diagnostics are source-ordered. slc check and slc run report the same compiler diagnostics. run continues into evaluation only when the phases accept the program.

Some slips name the repair directly. A handler clause with the wrong number of parameters reports the operation's arity. A clause of the wrong answer type reports the handler's answer type. An incomplete handler lists the missing operations and mentions a final _ => forward. A function closed with > where the > was meant to be left off is reported as a function applied by flow. A clause that names no operation is refused by that name.

Runtime failures happen after evaluation starts. They are not compiler diagnostics and do not follow this order. They include:

  • division by zero, and arithmetic overflow, including an Into conversion or a sqrt that does not fit
  • a string index or substring outside the string
  • a read through a File that has been closed
  • a continuation that jumps across a reset which did not capture it

The programs in examples/errors/ fail on purpose. One is a command that reaches no continuation, one is a polarity the checker refuses, and one crosses reset at run time.