Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Log ¶
Log prints a located diagnostic: the path/line/column, the message, the offending source line, and an underline of the span, all colored by severity.
Diagnostics go to stderr, where the color detection already looks, so that a program's own output (show/write/peek, on stdout) can be redirected on its own without ANSI escapes and compiler noise landing in the file.
func ReportRuntimeError ¶
func ReportRuntimeError(err *RuntimeError)
ReportRuntimeError prints a RuntimeError: the message (located at its source span when one is known) followed by the chain of bindings that led to it.
Types ¶
type RuntimeError ¶
A RuntimeError is raised (by panic) when a program cannot continue: a non-exhaustive match, applying a non-function, a non-number passed to an arithmetic primitive, a malformed argument to write. It carries what is needed to report the failure in the programmer's terms: a message, the source span of the offending expression (when known), and a reduction trace.
The trace is the closest thing a lazy language has to a stack trace. The Go call stack is useless here — a thunk is built in one place and forced in another, so the host stack does not mirror the program's logical call structure. Instead the machine records the names of the bindings (let / module / pattern) whose evaluation was in progress when the error happened; see collectTrace in machine.go. Anonymous intermediate thunks are skipped, leaving a readable skeleton like `while reducing: a → b → c`.
RuntimeError is recovered at the run boundary (Run in machine.go). Bare, non-RuntimeError panics are left to propagate with their Go stack trace: they indicate a compiler/machine bug, not a program error.
func (*RuntimeError) Error ¶
func (e *RuntimeError) Error() string
type Source ¶
A Source is one loaded source file: its path and full text. Spans (SourcePos) point into it.