fix: apply method receiver offset when generating interface wrapper

Fixes #772.
This commit is contained in:
Marc Vertes
2020-07-12 14:20:03 +02:00
committed by GitHub
parent ca80ada849
commit 0c8f538cd9
2 changed files with 32 additions and 1 deletions

31
_test/issue-772.go Normal file
View File

@@ -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!!

View File

@@ -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