Skip to content

text/template: panic in mistyped call #3267

@rsc

Description

@rsc
It looks like the text/template type checker is supposed to figure this out?  Or at
least not panic?

http://play.golang.org/p/ArLMq7u57U


package main

import (
    "log"
    "os"
    "text/template"
)

type T string

func main() {
    m := template.FuncMap{
        "f": func() T { return "hello" },
        "g": func(s string) string { return s },
    }
    t := template.Must(template.New("main").Funcs(m).Parse(`{{f|g}}`))
    log.Fatal(t.Execute(os.Stdout, nil))
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions