-
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
text/template: incorrect range syntax is accepted by the parser #28437
Comments
Minified repro: https://play.golang.org/p/266xq0CRTIY Without digging into this, it seems like broken syntax to me. I presume that's why you don't necessarily think that this is a bug in 1.11. Do you have another reason to call this a regression, besides it having worked on 1.10? For example, did it work on many previous Go versions, or does the syntax make sense following any previous |
Yes, but it depends on the definition of "a bug". It has broken some apps/sites that worked before Go 1.11, but the error message is loud and clear, which is good. |
Yes - agreed that this isn't a clear case. Given that the template doesn't make sense, appears to be undocumented behavior, and errors out in an obvious way, I'm leaning towards leaving things the way they are. It would be a different scenario if templates were breaking in silent or hard to debug ways, or if the template made some sense syntactically. If you think we should do something, do you have anything in mind besides reverting to 1.10's behavior? If we did that, we'd likely have to document this syntax and add regression tests for it, which I presume is not something we want to do. /cc @robpike for a second opinion. |
I think you should just leave it as is. This issue can serve as documentation. Some people have found an "accidental feature" that is for most people (and according to documentation) obvious wrong syntax. I created this issue out of curiousness more than anything. |
Agreed. I'm curious as to exactly what CL fixed this weird behavior, and I'd like to add a regression test, so I'll leave this issue open until I have a look at that. |
This actually is a bug. This is a subtle syntax parser bug that has existed for a while. Both 1.10 and 1.11 parse the template with no errors, which is incorrect. Will send a fix shortly, which should mean that the error happens sooner and has a clearer message. |
Change https://golang.org/cl/145282 mentions this issue: |
@bep please take a look at the CL above, and feel free to give it a try. With my minified program using
I don't know if you're on Gerrit, but reviews are very much welcome :) |
Note: This isn't me suggesting that you should fix this. I have had some people reporting broken Hugo sites because of this, and I was "I don't see how that can have worked" until the third person arrived with the same issue.
The program below works on Go 1.10, fails in Go 1.11:
https://play.golang.org/p/5xrifxQFHQd
The text was updated successfully, but these errors were encountered: