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: type checker bug with missing map keys #3850
Labels
Comments
I expect the following change but it breaks the tests. diff -r 5e7fd762f356 src/pkg/text/template/funcs.go --- a/src/pkg/text/template/funcs.go Tue Jul 17 07:56:25 2012 +0200 +++ b/src/pkg/text/template/funcs.go Sun Jul 22 12:07:02 2012 +0200 @@ -128,7 +128,7 @@ if x := v.MapIndex(index); x.IsValid() { v = x } else { - v = reflect.Zero(v.Type().Key()) + v = reflect.Zero(v.Type().Elem()) } default: return nil, fmt.Errorf("can't index item of type %s", index.Type()) |
Labels changed: added priority-soon, packagebug, removed priority-triage. Owner changed to @robpike. Status changed to Accepted. |
This issue was closed by revision ce27433. Status changed to Fixed. |
robpike
added a commit
that referenced
this issue
May 11, 2015
««« backport 0748cd92ed76 text/template: fix bug in map indexing If the key is not present, return value of the type of the element not the type of the key. Also fix a test that should have caught this case. Fixes #3850. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/6405078 »»»
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: