Say why an empty name is rejected, and finish what that removed
Tests / vet + fmt + tests (push) Failing after 42s

The reason given was wrong. A dot path did reach an empty-named field:
Fake("a.") returned it, Fake("a.b.") returned a nested one, and {..a.} bound
it. What was true is narrower — List never offered it, because an empty name
is no path segment — so the engine accepted spellings it would not advertise.
The message, the test comment and the README say that instead.

Two things the rejection finished off:

A {} token still reported "no field \"\"", pointing at a fix the loader now
rejects — two errors for one rule. It is told the name can never exist, like
an option token already is.

addressable is dead: both halves of "not empty and no dot" are now rejected
where a name is authored. Mutating it to panic leaves the suite green here
and panics on main, so it was live and is not. Keeping it would preserve the
silent-hiding this change removes — List quietly omitting a name rather than
New refusing it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
M
2026-08-31 22:38:01 +02:00
committed by lilleman-tw
parent 138bd21d83
commit 64a0d29496
5 changed files with 18 additions and 20 deletions
+1 -1
View File
@@ -267,7 +267,7 @@ var reservedList = strings.Join(strings.Split(reservedInName, ""), " ")
// name may contain.
func checkName(name string) error {
if name == "" {
return fmt.Errorf("%q is empty, so no dot path can reach it", name)
return fmt.Errorf("%q is empty, which is not a path segment, so List never offers it", name)
}
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",