Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text/template: panic in mistyped call #3267

Closed
rsc opened this issue Mar 10, 2012 · 4 comments
Closed

text/template: panic in mistyped call #3267

rsc opened this issue Mar 10, 2012 · 4 comments
Assignees

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Mar 10, 2012

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))
}
@robpike
Copy link
Contributor

@robpike robpike commented Mar 26, 2012

Comment 1:

Status changed to Started.

@rsc
Copy link
Contributor Author

@rsc rsc commented Mar 26, 2012

Comment 2:

Rob has a pending CL.
For after Go 1 now.

Labels changed: added priority-later, removed priority-go1.

@robpike
Copy link
Contributor

@robpike robpike commented Apr 3, 2012

Comment 3:

This issue was closed by revision 065db4e.

Status changed to Fixed.

@robpike
Copy link
Contributor

@robpike robpike commented Apr 25, 2012

Comment 4:

This issue was closed by revision 7ea5621897b9.

@rsc rsc added fixed labels Apr 25, 2012
robpike added a commit that referenced this issue May 11, 2015
««« backport c007925a75c6
text/template: pipelined arg was not typechecked
Without this fix, an erroneous template causes a panic; should be caught safely.
The bug did not affect correct templates.

Fixes #3267.

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5900065
»»»
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.