Read one value when a bound path is read twice

This commit is contained in:
M
2026-08-28 15:06:10 +02:00
committed by lilleman-tw
parent 12100239f5
commit a25b42ace2
3 changed files with 62 additions and 20 deletions
+4 -3
View File
@@ -177,6 +177,7 @@ func fieldTokens(format string) []string {
// bound under) and the tail of a dotted path into it. A non-empty tail is what makes
// the arm a bound draw: its head is drawn once per expansion (see boundHeads).
type arm struct {
name string // as written, and the key a bound draw's value is held under
key string
tail []string
}
@@ -185,13 +186,13 @@ type arm struct {
// dots — linkRefs binds it whole — so only a sibling name reads as a path.
func splitArm(name string) arm {
if isRef(name) {
return arm{key: name}
return arm{name: name, key: name}
}
head, tail, dotted := strings.Cut(name, ".")
if !dotted {
return arm{key: name}
return arm{name: name, key: name}
}
return arm{key: head, tail: strings.Split(tail, ".")}
return arm{name: name, key: head, tail: strings.Split(tail, ".")}
}
// splitArms splits a token body's '|' alternatives.