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

zuri.diagnostic

import zuri

Everything here is re-exported by zuri, so import zuri is enough and the names are called as zuri.*. Importing zuri.diagnostic on its own works too and reaches the same definitions.

The Diagnostic type: one problem found in a piece of Zuri source by reading it rather than running it, as zuri.parse_partial() and zuri.check() reports them.

Classes

Diagnostic

class zuri.Diagnostic

One problem in a piece of Zuri source: what is wrong and exactly where.

The position has the same six parts a zuri.ast.Node has. start and end are character offsets, the first character the problem is about and the one just past it, so source[d.start, d.end] is the text it is about. line and col are where that text starts and end_line and end_col where it ends, all counted from 1.

A syntax error covers the token it is about. When the source ends where more was expected, that is an empty span at the very end. A compiler error covers the token it is about, or the whole of its line when it belongs to the line rather than to one token.

  • printable — has a @to_string(), so echo and print() show something useful

Constructor

zuri.Diagnostic(message: string, position: dict)

Returns a new Diagnostic. Ordinary code receives these from zuri.parse_partial() and zuri.check() rather than building them.

Parameters

  • message (string) — What is wrong, without a position
  • position (dict) — { start, end, line, col, end_line, end_col }

Diagnostic.to_string()

zuri.Diagnostic.to_string() -> string

This diagnostic as line:col: message, e.g. '2:3: 'break' used outside of a loop'.

Returns string


2026, Richard Ore and Zuri contributors