diff --git a/_test/issue-772.go b/_test/issue-772.go new file mode 100644 index 00000000..98ed9a97 --- /dev/null +++ b/_test/issue-772.go @@ -0,0 +1,31 @@ +package main + +import ( + "log" + "os" + "text/template" +) + +type Message struct { + Data string +} + +func main() { + tmpl := template.New("name") + + _, err := tmpl.Parse("{{.Data}}") + if err != nil { + log.Fatal(err) + } + + err = tmpl.Execute(os.Stdout, Message{ + Data: "Hello, World!!", + }) + + if err != nil { + log.Fatal(err) + } +} + +// Output: +// Hello, World!! diff --git a/interp/run.go b/interp/run.go index 9db530aa..a1ee5514 100644 --- a/interp/run.go +++ b/interp/run.go @@ -1080,7 +1080,7 @@ func callBin(n *node) { } for i, c := range child { - defType := funcType.In(pindex(i, variadic)) + defType := funcType.In(rcvrOffset + pindex(i, variadic)) switch { case isBinCall(c): // Handle nested function calls: pass returned values as arguments