Parse and check a format in one call, keeping compileTemplate under the complexity gate

This commit is contained in:
2026-09-24 23:27:25 +02:00
committed by Lillem4n
parent 467cb6fb18
commit 2a7499e93c
2 changed files with 10 additions and 8 deletions
+8
View File
@@ -185,6 +185,14 @@ func checkFunc(tok formatToken, fields map[string]node) error {
return nil
}
func parseChecked(format string, fields map[string]node) ([]formatToken, error) {
toks, err := parseFormat(format)
if err != nil {
return nil, err
}
return toks, checkTokens(toks, fields)
}
// checkTokens proves every parsed token names an existing field or a known function,
// so a typo'd or dangling reference is a New-time error.
func checkTokens(toks []formatToken, fields map[string]node) error {