# Sonata 0.1 — diagnostics
Every diagnostic has a stable code, a severity, a source span, a message, and when possible a
suggestion and a fix (a text edit that is safe to apply automatically). Codes never change
meaning; a retired code is never reused. A test checks that this page lists every code the
toolchain can emit.
sonata check --json and the editor expose the same structure (sonata_ir::Diagnostic):
code, severity, span {file, start, end} (byte offsets), message, suggestion,
fix {title, span, replacement}, related [{span, message}], plus a resolved location
(file name, 1-based line and column).
When a file has lexical or syntax errors, semantic analysis is not reported for that
compilation: the tree is incomplete and its errors would be noise. Fix the syntax first.
# L0xxx — lexer
| Code |
Meaning |
Fix offered |
| L0001 |
Unexpected character (a run of them is reported once). |
|
| L0002 |
A string is not closed before the end of its line. |
insert " |
| L0003 |
A block comment /* … */ is never closed. |
|
| L0004 |
Unknown unit suffix glued to a number (12bmp). |
the unit with the same letters (BPM → bpm) |
| L0005 |
Invalid escape sequence in a string. |
|
| L0006 |
Integer literal does not fit in 64 bits. |
|
| L0007 |
Source larger than 4 MiB. |
|
| L0008 |
Source is not valid UTF-8. |
|
# P1xxx — parser
| Code |
Meaning |
Fix offered |
| P1001 |
Expected a statement, an item or an instrument member; found something else. |
closest keyword at top level |
| P1002 |
Expected a specific token ({, :, =, a name, …). |
insert the token |
| P1003 |
A block, list, parenthesis or argument list is never closed. |
insert the closer |
| P1004 |
Blocks or expressions nested deeper than 96 levels. |
|
| P1005 |
Expected an expression; or a parameter or setting has no value. |
|
| P1006 |
A signature is not two integers (signature 4/4). |
|
| P1007 |
Unknown modifier after play / chord. |
closest modifier |
| P1008 |
Invalid version line (sonata 0.1). |
|
| P1009 |
Item not allowed here (import, fn, pattern, composition below top level; model, preset, graph, node, out outside an instrument definition). |
|
| P1010 |
A reserved word is used as a name. |
|
| P1011 |
A note or pitch-class literal (A4, Bb) is used as a name. |
|
| P1012 |
A graph has more than one out. |
|
| P1013 |
Two statements on one line without ;. |
insert ; |
# S2xxx — symbols, scopes, registry names
| Code |
Meaning |
Fix offered |
| S2001 |
Unknown name: variable, function, instrument, bus, mode, chord quality, articulation, curve, or an effect that the strip does not have. |
closest known name |
| S2002 |
A name is defined twice at top level, or redefines a built-in. |
|
| S2003 |
A name is used as the wrong kind of thing (a function as a value, a pattern in an expression, a value as an instrument). |
|
| S2004 |
Unknown type in an annotation. |
closest type |
| S2005 |
Wrong arguments: count, unknown or repeated name, positional after named, unnamed argument where names are required. |
closest parameter |
| S2006 |
A top-level constant depends on itself. |
|
| S2007 |
Assignment to a constant or to a top-level definition. |
|
| S2008 |
Statement not allowed in this context (play in a bus, return in a track, …). |
|
| S2009 |
Unknown setting, clip option or default in this context. |
closest setting |
| S2010 |
No composition has the requested title. |
|
| S2011 |
A track or a bus is declared twice. |
|
| S2012 |
Instrument inheritance cycle. |
|
| S2020 |
Unknown engine model. |
closest model |
| S2021 |
Unknown effect. |
closest effect |
| S2022 |
Unknown preset of an engine or effect. |
closest preset |
| S2023 |
Unknown parameter or slot of an engine or effect. |
closest parameter |
| S2024 |
Value is not one of the choices of a parameter. |
closest choice |
| S2025 |
An instrument definition has no model (own or inherited). |
|
| S2026 |
Unknown patch node, or unknown port of a node. |
closest name |
| S2027 |
A derived instrument tries to change the model it inherits. |
|
# T3xxx — types and units
| Code |
Meaning |
Fix offered |
| T3001 |
Operator applied to incompatible types (1s + 1/4, D4 + 2), wrong operand type. |
|
| T3002 |
Wrong argument type for a built-in function. |
|
| T3003 |
A musical duration was expected (seconds or a float were given). |
|
| T3004 |
A pitch or a list of pitches was expected by play / chord. |
add octave to a pitch class |
| T3005 |
Value outside the documented range of a parameter, setting or function. |
|
| T3006 |
Wrong dimension for a parameter or setting (a number where dB, Hz, a time or an interval is required, …). |
append the unit to a literal |
| T3007 |
Division by zero. |
|
| T3008 |
List index out of range, or an empty list where an element is needed. |
|
| T3009 |
Value does not match its type annotation; a function does not return its declared type on every path. |
|
| T3010 |
The type exists in the language but is not a value type in 0.1 (Signal, Instrument, …). |
|
| T3011 |
A condition is not a Bool. |
|
| T3012 |
for over something that is not a list or a range. |
|
| T3013 |
Unknown member (xs.size), unknown note. value in a graph. |
closest name |
| T3014 |
The parameter cannot be automated. |
|
# M4xxx — musical validation
| Code |
Severity |
Meaning |
| M4001 |
warning |
Note outside the playable range of the instrument (rendered anyway; at most 5 per track). |
| M4002 |
error |
Signature change not on a bar line. |
| M4003 |
error |
Tempo outside [1, 1000] bpm, or invalid tempo map. |
| M4004 |
error |
Two different tempos set at the same position. |
| M4005 |
warning |
A tie has no continuation (no adjacent note of the same pitch in the same voice). |
| M4006 |
error |
Swing ratio outside [50 %, 75 %]. |
| M4007 |
error |
Invalid signature (numerator 1–64, denominator a power of two up to 64). |
| M4008 |
error |
Velocity outside [0, 1]. |
| M4009 |
error |
Zero or negative duration (note, rest, ramp, swing unit). |
| M4010 |
error |
Negative position. |
| M4011 |
error |
Automation or bend points out of time order, or an automation without point. |
| M4012 |
error |
Unsupported sample rate. |
| M4013 |
error |
peak_limit outside [-60, 0] dBFS. |
| M4014 |
warning |
The composition has no track. |
| M4015 |
error |
Invalid tuplet numbers. |
| M4016 |
error |
tuning outside [220, 880] Hz. |
| M4018 |
error |
degree() used without a key. |
(M4017 was never assigned.)
# G5xxx — DSP graphs
| Code |
Meaning |
| G5001 |
Bus routing forms a loop, or a bus is routed to itself. The loop is listed in the message. |
| G5002 |
A patch node reads a node computed later without going through delay(in: …); aliases that only refer to each other. |
| G5003 |
A graph has no out. |
| G5004 |
graph used with a model other than patch, or model patch without a graph. |
| G5005 |
Operation not available between signals (division by a signal; the engine lacks the node an operator needs). |
| G5006 |
Expression that cannot be used with signals (comparison, list, …). |
| G5007 |
The graph output is a constant, a note value or a control-rate signal instead of audio. |
| G5008 |
A constant-only port is driven by a signal. |
| G5009 |
Node defined twice, or named note. |
| G5010 |
A strip is routed to a bus that does not exist (only reachable with a hand-built Program). |
| G5011 |
Warning: a named patch node does not reach the output; it is removed from the instrument. |
| G5099 |
Internal error: the generated graph failed its own validation. Please report it. |
# Q6xxx — quotas
Defaults in parentheses; all configurable through CompileOptions::quotas. A quota error
stops the compilation cleanly at the statement that crossed the limit.
| Code |
Limit |
| Q6001 |
Notes in a composition (1 000 000). |
| Q6002 |
Evaluation steps (10 000 000). |
| Q6003 |
Call depth (64), or combined nesting of blocks, calls and expressions (4 096). |
| Q6004 |
List length (100 000). |
| Q6005 |
Exact musical time overflowed 64-bit rationals. Never wraps. |
| Q6006 |
Tracks (256). |
| Q6007 |
Nodes in a patch (4 096). |
| Q6008 |
Diagnostics (200): analysis stops instead of flooding. |
# I7xxx — imports, modules, assets
| Code |
Meaning |
Fix offered |
| I7001 |
Module not found. |
closest standard module |
| I7002 |
Import cycle (the chain is listed). |
|
| I7003 |
Imports nested deeper than 16 levels. |
|
| I7004 |
The file asks for a newer language version than the toolchain implements. |
|
| I7005 |
Unsafe asset path in clip (absolute, .., backslash, control character, empty component). |
|