Drop the unreachable reference-prefix checks
A name starting with ".." also starts with ".", so loadDir's hidden-entry skip reaches it first and neither isRef branch could ever fire. Removed, and the comment in named now names the skip that actually holds the invariant it depends on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,9 +61,6 @@ func loadDir(dir string) (*group, error) {
|
|||||||
}
|
}
|
||||||
full := filepath.Join(dir, e.Name())
|
full := filepath.Join(dir, e.Name())
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
if isRef(e.Name()) {
|
|
||||||
return nil, fmt.Errorf("%s: folder %q starts with %q, which is reserved for {..path} bindings", full, e.Name(), refPrefix)
|
|
||||||
}
|
|
||||||
child, err := loadDir(full)
|
child, err := loadDir(full)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -81,9 +78,6 @@ func loadDir(dir string) (*group, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
name := strings.TrimSuffix(e.Name(), ".json")
|
name := strings.TrimSuffix(e.Name(), ".json")
|
||||||
if isRef(name) {
|
|
||||||
return nil, fmt.Errorf("%s: category %q starts with %q, which is reserved for {..path} bindings", full, name, refPrefix)
|
|
||||||
}
|
|
||||||
if err := checkName(name); err != nil {
|
if err := checkName(name); err != nil {
|
||||||
return nil, fmt.Errorf("%s: category %w", full, err)
|
return nil, fmt.Errorf("%s: category %w", full, err)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -170,8 +170,8 @@ func contained(n node) []namedNode {
|
|||||||
|
|
||||||
// named skips a bound {..path} key: it is a render edge, not containment, so using
|
// named skips a bound {..path} key: it is a render edge, not containment, so using
|
||||||
// it as a path segment would report a node under a path that does not reach it. Only
|
// it as a path segment would report a node under a path that does not reach it. Only
|
||||||
// a template's fields hold bindings — loadDir rejects a category or folder carrying
|
// a template's fields hold bindings — loadDir skips a dot-prefixed entry, so a
|
||||||
// the prefix — so this one skip serves a group's children too.
|
// group's children never carry the prefix — so this one skip serves both.
|
||||||
func named(m map[string]node) []namedNode {
|
func named(m map[string]node) []namedNode {
|
||||||
out := make([]namedNode, 0, len(m))
|
out := make([]namedNode, 0, len(m))
|
||||||
for _, name := range sortedNames(m) {
|
for _, name := range sortedNames(m) {
|
||||||
|
|||||||
Reference in New Issue
Block a user