GocciaRunner's runtime suggestions name catalogue constants and are checked against the engine
Date: 2026-12-01
Area: errors, cli
Related: #2489,
#2510,
#2513, Errors — Runtime suggestions
Context
GocciaRunner prints a Suggestion: line for a runtime error from a table of message templates and suggestions,
source/app/GocciaRunner.Suggestions.inc. scripts/engine/gen_suggestions.py built it from the previous engine's
throw sites, which passed a catalogue message and a catalogue suggestion together
(ThrowTypeError(SErrorX, SSuggestY)). The current engine throws a message alone: a literal text, a catalogue
constant, or, in a prelude script, a JavaScript string. Run on that engine, the generator found 1 row against the
committed 547, and 368 of those 547 templates could no longer match anything thrown, so their suggestions never showed
(one, The number %s cannot be converted to a BigInt ..., because its throw site leaves the number out).
Nine more were thrown, but with a suggestion that did not fit: Invalid index (BigInt's hint for Array, TypedArray
and Atomics errors), Converting circular structure to JSON and ... to JSON5 ("ensure the string contains valid
JSON" for a stringify), Cyclic __proto__ value, the two roundingIncrement range errors, Cannot convert %s to a BigInt ("use BigInt()" for a failed BigInt() call), Cannot set property on non-object (a null check for a write
to a primitive) and the FFI file-URL error ("open a library first with FFI.open" from inside FFI.open).
Nothing checked the table. The issue left the mechanism open: throw sites that pass catalogue constants, or a
generator that also reads literal texts paired with a suggestion beside them.
The pairing of a message with its suggestion now exists only in the table. Prelude scripts cannot name a Pascal constant, so a check that accepts only constant references would reject rows whose messages the preludes do throw.
Decision
- The table is source, not generated: each row names a message template from
Goccia.Error.Messagesand a suggestion fromGoccia.Error.Suggestions((SErrorSymbolConstructorRequiresCall, SSuggestSymbolNoNew)). The compiler resolves their texts, so there is no generated copy to drift, andgen_suggestions.pyis gone. scripts/check-runtime-suggestions.tschecks the table in CI (thetest-structurejob): every row's template must be thrown, either by a Pascal source undersource/engineorsource/unitsthat names its constant, or by one such source or prelude script whose string literals hold its text between placeholders (the catalogues themselves, Pascal tests andsource/engine/toolsare left out). The template's first run of text must start a literal and its last must end one. A run may be split across two literals of the same source only when the second continues an expression (it follows+or a template literal's substitution), and only at a word boundary. Rows must also name constants that exist, have unique ASCII templates, and have enough text besides their placeholders to tell apart.- The most specific matching template wins: of the templates that match a message, the one with the most text
besides its
%s,%dand%xgives the suggestion (#2510). The table's order matters only on a tie, where the earlier row wins. - A throw site gets a suggestion by throwing the catalogue's text, through the constant or the same text, and a
row in the table. The engine's own per-error suggestion (
SetErrorHostSuggestion) still comes first.
Consequences
- The table keeps 170 of the old rows, those the engine still throws less the nine above, and adds one for a class
without a name called without
new(#2513); the suggestions keep their texts. A row whose message the engine stops throwing fails CI instead of going quiet. - The literal-text check is a heuristic: a message assembled from more than two literals around a placeholder-free
run, or from text held outside string literals, is not seen, and a literal that holds a template's text without
being thrown counts. A row the check cannot see is added by making its throw site use the catalogue constant. The
check shows that a template is thrown, not that its suggestion fits every site that throws it, and a template's
first and last runs can both come from one literal with nothing between them, so a throw site that leaves a
placeholder's text out (and the space around it) still counts. The two literals of a
split need not be next to each other, and the Pascal scanner ends a
{ }comment at its first}, so a nested brace in a comment before a unit's{$mode}directive can make comment prose count. - Engine messages that still differ from the catalogue's texts get no table suggestion until their throw sites move to the catalogue, as #2488 did for the iteration errors.