10.1.1 How it works
Every diagnostic has these parts:
| Part | What it is |
|---|---|
| code | a stable name, the same in every language |
| class | lexical, syntactic, semantic or runtime |
| severity | error, warning or information |
| span | where it starts and ends in the text |
| related | other spans that help understand it |
| arguments | the concrete data: a name, a type, a number |
At the top, the diagnostic as data: code incompatibleTypesInAssignment, semantic class and error severity, span on line 2 and arguments expected Integer and found String. An arrow with the language template leads to the presented message.
ProgramA diagnostic with arguments
Algorithm Mezcla
Define total As Integer <- "diez";
Write total;
EndAlgorithmDiagnostics
incompatibleTypesInAssignment· error · 2:3 · Incompatible types in assignment: cannot assign string to integer
The program finishes with an error.
The data carries no text. To show it, the interface looks up the code's template in its language and fills in the arguments. That is why the message prose can be in English while the program uses the Spanish profile: user names are never translated, and the language's words appear in the active profile.
Appendix C lists every code with its class, severity and message.
In short
- A diagnostic is data: code, class, severity, span and arguments.
- The message is built afterwards, with the language's template.
- The code does not change with the language.