diff --git a/drawfence.go b/drawfence.go index 325695e..42910b3 100644 --- a/drawfence.go +++ b/drawfence.go @@ -90,8 +90,8 @@ func checkOwnFamily(t *template) error { seen[n] = true for _, e := range renderEdges(n) { if e.readsRef() { - if head, isTable := n.(*template).head(e.read.head).(*table); isTable && head.familyRoot() == own.familyRoot() { - return e, head, true + if read, isTable := n.(*template).head(e.read.head).(*table); isTable && read.familyRoot() == own.familyRoot() { + return e, read, true } } if e, head, found := find(e.to); found { diff --git a/format.go b/format.go index d9849c5..98ab09b 100644 --- a/format.go +++ b/format.go @@ -322,11 +322,11 @@ func splitArm(name string, refs map[string]refBinding) arm { if !linked || len(b.tail) == 0 { head := name if linked { - head = b.key + head = b.head } return arm{spelling: name, head: head, path: head} } - return pathArm(name, b.key, b.tail) + return pathArm(name, b.head, b.tail) } segs, err := splitPath(name) if err != nil || len(segs) == 1 { @@ -371,7 +371,7 @@ type callFn func(s *session, emitted string, operands []string) string // re-scans the format. type op struct { formatToken - arms []arm // nameRead: the '|' alternatives, split into key and path once + arms []arm // nameRead: the '|' alternatives, split into head and tail once call callFn // operands are the fields the builtin reads, in the order its operands func // fixed; expand reads them before the call. nil for a builtin that reads none. diff --git a/node.go b/node.go index fc53753..9fc2867 100644 --- a/node.go +++ b/node.go @@ -74,7 +74,7 @@ const formatRow = -1 // templateLink is what a template resolves to in the assembled tree. type templateLink struct { refs map[string]refBinding // each reference the format reads -> what it resolves to - refHeads map[string]node // each refBinding.key -> the category it names + refHeads map[string]node // each refBinding.head -> the category it names readsColumn *columnRead // set when the format is one reference alone reading a record's column drawGroupKey string // its draw group keyed by its category: what a render reads its reference paths under } diff --git a/reference.go b/reference.go index 03e2902..62c477c 100644 --- a/reference.go +++ b/reference.go @@ -9,10 +9,10 @@ import ( // data root, {.a} from the folder this file sits in, {..a} from the folder above. func isRef(name string) bool { return strings.HasPrefix(name, ".") || strings.HasPrefix(name, "/") } -// refBinding is what a reference resolves to: the key its category is held +// refBinding is what a reference resolves to: the head its category is held // under, and the tail read into it. type refBinding struct { - key string + head string tail []string } @@ -119,15 +119,15 @@ func (t *template) resolveLink(folder []string, path, category string, root map[ if err != nil { return link, fmt.Errorf("%s: reference {%s}: %w", path, name, err) } - key := "/" + strings.Join(categorySegs, ".") - if category != "" && key == "/"+category { + head := "/" + strings.Join(categorySegs, ".") + if category != "" && head == "/"+category { return link, fmt.Errorf("%s: reference {%s}: names the category it sits in; read a sibling field as a path, or move the shared value into its own category and reference that", path, name) } - if err := checkPath(target, tail, key); err != nil { + if err := checkPath(target, tail, head); err != nil { return link, fmt.Errorf("%s: reference {%s}: %w", path, name, err) } - link.refHeads[key] = target - link.refs[name] = refBinding{key, tail} + link.refHeads[head] = target + link.refs[name] = refBinding{head, tail} } link.readsColumn = columnReadOf(t, link) return link, nil diff --git a/shape_test.go b/shape_test.go index 010b2fe..50d48f2 100644 --- a/shape_test.go +++ b/shape_test.go @@ -102,7 +102,7 @@ func readsFact(n node) string { } case *template: for _, b := range n.link.refs { - set[strings.TrimPrefix(b.key, "/")] = true + set[strings.TrimPrefix(b.head, "/")] = true } for _, field := range n.fields { collect(field)