Accept a name as a calc operand

This commit is contained in:
2026-10-05 00:55:13 +02:00
committed by Lillem4n
parent 3d320e029c
commit b4052f77f9
7 changed files with 114 additions and 63 deletions
+3 -7
View File
@@ -26,15 +26,11 @@ func checkNameReads(path string, t *template) error {
})
}
// checkUses refuses a binding of a category read once whole, and reads of b in two draw groups,
// checkUses refuses a binding of a category read once whole, outside a calc, which takes no reference, and reads of b in two draw groups,
// or inside a repeat, where what b names reads a reference path.
func (b *nameBinding) checkUses() error {
if r := b.uses[0]; len(b.uses) == 1 && r.tail == "" && !r.nested && len(b.tail) == 0 {
spelling := b.ref
if !r.operand {
spelling = "{" + spelling + "}"
}
return fmt.Errorf("name %q is read once, whole, which the bare reference draws the same way; write %s where it is read, and drop the token", b.name, spelling)
if r := b.uses[0]; len(b.uses) == 1 && r.tail == "" && !r.nested && !r.operand && len(b.tail) == 0 {
return fmt.Errorf("name %q is read once, whole, which the bare reference draws the same way; write {%s} where it is read, and drop the token", b.name, b.ref)
}
if !readsHeld(b.head, map[node]bool{}) {
return nil