Reject an empty field name

A field named "" was reachable by exactly one spelling, a bare {} token,
and by no dot path: List hid it and Fake could not ask for it. checkName
rejects it now, for the reason it rejects a dot — a name no path can reach.

That also makes the empty-segment rule unconditional. {a.} was rejected
because a field really named "" would otherwise have made it resolve; no
data can carry one, so the rule now guards a shape that cannot exist.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
M
2026-08-31 22:10:45 +02:00
committed by lilleman-tw
parent e31e77b8a3
commit 138bd21d83
+3
View File
@@ -266,6 +266,9 @@ var reservedList = strings.Join(strings.Split(reservedInName, ""), " ")
// category or folder and a field go through it, so there is one answer to what a // category or folder and a field go through it, so there is one answer to what a
// name may contain. // name may contain.
func checkName(name string) error { func checkName(name string) error {
if name == "" {
return fmt.Errorf("%q is empty, so no dot path can reach it", name)
}
if i := strings.IndexAny(name, reservedInName); i >= 0 { if i := strings.IndexAny(name, reservedInName); i >= 0 {
return fmt.Errorf("%q contains %q; a name may not use %s, which the dot path and {token} grammars reserve", return fmt.Errorf("%q contains %q; a name may not use %s, which the dot path and {token} grammars reserve",
name, name[i:i+1], reservedList) name, name[i:i+1], reservedList)