Say why an empty name is rejected, and finish what that removed
Tests / vet + fmt + tests (push) Failing after 42s
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:
@@ -147,6 +147,9 @@ func checkTokens(format string, fields map[string]node) error {
|
||||
}
|
||||
head, ok := fields[a.key]
|
||||
if !ok {
|
||||
if a.key == "" {
|
||||
return fmt.Errorf("token {%s}: a name is never empty, so this token can name no field", t.body)
|
||||
}
|
||||
if isOption(a.key) {
|
||||
return fmt.Errorf("token {%s}: %q is an option and can never be a field", t.body, a.key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user