Address reviewer findings: reference hint, consumer-terms type errors, misuse exit code, immutability and parity docs
Tests / vet + fmt + tests (pull_request) Successful in 57s

This commit is contained in:
2026-09-03 19:21:42 +02:00
parent 4d58c93757
commit 873b7678ba
7 changed files with 52 additions and 11 deletions
+15 -1
View File
@@ -87,10 +87,24 @@ func compileItem(v any) (node, error) {
case map[string]any:
return compileTemplate(v)
default:
return nil, fmt.Errorf("unsupported node type %T", v)
return nil, fmt.Errorf("a template value must be a string, a list or an object, not %s", jsonKind(v))
}
}
// jsonKind names a JSON value a template cannot hold, in the data format's own
// terms rather than the decoding library's.
func jsonKind(v any) string {
switch v.(type) {
case float64:
return "a number"
case bool:
return "a boolean"
case nil:
return "null"
}
return fmt.Sprintf("%T", v)
}
func compileString(s string) (node, error) {
if err := checkTokens(s, nil); err != nil {
return nil, err