From e0969e69e7197d4d3f8e3473e815d7cc08647d00 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 28 Sep 2026 02:48:24 +0200 Subject: [PATCH] Want every format compiled at link, not only one holding a reference --- node_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/node_test.go b/node_test.go index 5685849..f0cee3d 100644 --- a/node_test.go +++ b/node_test.go @@ -80,3 +80,37 @@ func TestNodeCompileErrors(t *testing.T) { } } } + +func TestEveryFormatCompilesAtLink(t *testing.T) { + n, err := compile(parse(t, `{"format":"{a} {b}","a":{"format":"x{c}","c":["1","2"]},"b":"{/w}"}`)) + if err != nil { + t.Fatal(err) + } + w, err := compile(parse(t, `["p","q"]`)) + if err != nil { + t.Fatal(err) + } + opsBy := func() map[string]bool { + compiled := map[string]bool{} + _ = eachNode(n, "t", func(path string, m node) error { + if tm, ok := m.(*template); ok { + compiled[path+" "+tm.format] = tm.ops != nil + } + return nil + }) + return compiled + } + for format, has := range opsBy() { + if has { + t.Errorf("%s compiled before link", format) + } + } + if err := bindInline(n, "t", map[string]node{"w": w}, func(nodeScope) error { return nil }); err != nil { + t.Fatal(err) + } + for format, has := range opsBy() { + if !has { + t.Errorf("%s not compiled at link", format) + } + } +}