Walk a template's fields in the shape test without skipping reference bindings

This commit is contained in:
2026-09-24 13:45:53 +02:00
committed by Lillem4n
parent 9f00ad039e
commit 84b3252bfc
+3 -4
View File
@@ -104,13 +104,11 @@ func readsFact(n node) string {
for _, b := range n.refs {
set[strings.TrimPrefix(b.key, "/")] = true
}
for name, field := range n.fields {
if !isRef(name) {
for _, field := range n.fields {
collect(field)
}
}
}
}
collect(n)
if len(set) == 0 {
return ""
@@ -130,8 +128,9 @@ func TestShippedShapeNamesReads(t *testing.T) {
"c": `{"format":"{v} {n}","n":[null,{"format":"{int(1,9)}","datatype":"integer"}],"v":["z","w"]}`,
"d/pos": `["{.q}","{/b}"]`,
"d/q": `"r"`,
"e": `"{/a}"`,
}))
want := "a\tformat \"{x}\"\treads b c\na.x\tstring\nb\tformat \"y\"\nc\tformat \"{v} {n}\"\nc.n\tinteger null\nc.v\tstring\nd.pos\treads b d.q\nd.q\tformat \"r\"\n"
want := "a\tformat \"{x}\"\treads b c\na.x\tstring\nb\tformat \"y\"\nc\tformat \"{v} {n}\"\nc.n\tinteger null\nc.v\tstring\nd.pos\treads b d.q\nd.q\tformat \"r\"\ne\tformat \"{/a}\"\treads a\n"
if got := shippedShape(f); got != want {
t.Fatalf("shippedShape =\n%s\nwant\n%s", got, want)
}