Give checkOwnFamily the scope walk's signature, and drop its wrapper
This commit is contained in:
@@ -257,7 +257,7 @@ func checkNodeFences(s nodeScope) error {
|
||||
return err
|
||||
}
|
||||
if refs {
|
||||
if err := s(checkOwnFamilies); err != nil {
|
||||
if err := s(checkOwnFamily); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s(fence.checkDraws); err != nil {
|
||||
|
||||
@@ -24,17 +24,6 @@ func (f *drawFence) checkDrawGroup(path string, n node) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkOwnFamilies(path string, n node) error {
|
||||
t, ok := n.(*template)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if err := checkOwnFamily(t); err != nil {
|
||||
return fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *drawFence) checkDraws(path string, n node) error {
|
||||
t, ok := n.(*template)
|
||||
if !ok {
|
||||
|
||||
+5
-4
@@ -258,11 +258,12 @@ func checkFamilies(reads []pathRead) error {
|
||||
// read draws its row without pinning it, so the family would draw apart from the row
|
||||
// it renders, whichever draws the reaching template holds.
|
||||
// docs/decisions.md#a-table-never-reaches-its-own-family-by-any-route
|
||||
func checkOwnFamily(t *template) error {
|
||||
own := t.site.table
|
||||
if own == nil {
|
||||
func checkOwnFamily(path string, n node) error {
|
||||
t, isTemplate := n.(*template)
|
||||
if !isTemplate || t.site.table == nil {
|
||||
return nil
|
||||
}
|
||||
own := t.site.table
|
||||
seen := map[node]bool{}
|
||||
var find func(n node) (renderEdge, *table, bool)
|
||||
find = func(n node) (renderEdge, *table, bool) {
|
||||
@@ -283,7 +284,7 @@ func checkOwnFamily(t *template) error {
|
||||
return renderEdge{}, nil, false
|
||||
}
|
||||
if e, familyTable, found := find(t); found {
|
||||
return fmt.Errorf("%s reads %s, a table of its own family, which a bare read of %s would draw apart from the row it renders; read the family from a template beside it, or add the value as a column", e.reached(), familyTable.segment, own.segment)
|
||||
return fmt.Errorf("%s: %s reads %s, a table of its own family, which a bare read of %s would draw apart from the row it renders; read the family from a template beside it, or add the value as a column", path, e.reached(), familyTable.segment, own.segment)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user