-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
html/template: behaviour of HTML templates changed between 1.7.5 and 1.8 #19294
Comments
If I change |
This is almost certainly a bug, and a mysterious one at that. Since it's a bug in text/template (the example uses html/template but the problem exists in the lower-level library) I can look at it. |
Reports on the mailing list say this one broke it:
|
I just run "git bisect" and it also came out with 2b583a1 as the first bad commit. |
In the breaking CL, it looks to me like
is checking the wrong thing tree. t.tmpl[new.name] is the interesting template, not t itself. Should probably be:
The non-determinacy of the example is likely due to html/template walking a map and making calls a variety of orders (that should all behave the same). |
Yes, I think that's the fix. |
@rsc's change fixes the test here but breaks the TestEmptyTemplate test. Working on it. |
CL https://golang.org/cl/38420 mentions this issue. |
Reopening for backport. |
CL https://golang.org/cl/39594 mentions this issue. |
Cherry-pick submitted. |
This was a subtle bug introduced in the previous release's fix for issue 16156. The definition of empty template was broken, causing the answer to depend on the order of templates in the map. Fixes #16156 (for real). Fixes #19294. Fixes #19204. Change-Id: I1cd915c94534cad3116d83bd158cbc28700510b9 Reviewed-on: https://go-review.googlesource.com/38420 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/39594 Reviewed-by: Rob Pike <r@golang.org>
This has not been fixed in 1.8.1 master.gohtml acount.gohtml template: master.gohtml:187:63: executing "DocumentFile" at <.FileFolder>: can't evaluate field FileFolder in type *auth.User masterTmpl account map[page:0xc042671150 account:0xc0424c38c0 accountGroups:0xc0427d4620] |
@minervadata Please post a complete program that reproduces the problem you are seeing. |
@robpike this is part of framework tmpl.go account.go master.gohtml |
This is not a complete program, it's several incomplete snippets from several files. You should be able to create a single, complete file of Go source code that can be compiled in isolation and demonstrate the problem. The template text can be constants in the source. Given your example I should be able to copy the text to file.go with no editing and run A playground link would be even better. |
Please open a new issue (golang.org/issue/new) for other problems with html/template. The error message you are reporting is unrelated to the failure this issue was about. |
What did you do?
When I use the html/template package I get non-deterministic output with Go version 1.8. The same program, when run with Go version 1.7.5 always gives the same output.
A minimal "working" example is here:
https://play.golang.org/p/2vVYZkiTFx
The program parses and executes the same template 100 times and counts how often it gets which output. On Go 1.8 I get results like
89
--- 11 ---What did you expect to see?
On Go 1.7.5 I always get the same output, namely the following:
100
---What did you see instead?
see above
System details
The text was updated successfully, but these errors were encountered: