-
Notifications
You must be signed in to change notification settings - Fork 18k
text/template: new keywords (e.g. break, continue) breaks older working programs #56538
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
Comments
cc @robpike |
FWIW, the change could be made non-breaking by only giving the new behavior to new keywords if they do not have a corresponding entry in the |
Yes, and that was also the original implementation (note that |
Any idea when specifically it regressed? https://go.dev/cl/410414 (for #53234) looks like a likely culprit to me (attn @eliben; CC @mvdan) |
Just a note that I can reproduce this with tip as well ( @robpike significantly refactored the template lexer for 1.20 (https://go-review.googlesource.com/c/go/+/421883) but this doesn't affect the issue (it works in 1.18 but not 1.19 or 1.20) |
Indeed, https://go-review.googlesource.com/c/go/+/410414 is the culprit as @bcmills suspected. The fix is straightforward; I want to spend a bit of time devising tests, since it's annoying that the package's tests didn't catch this bug. |
Change https://go.dev/cl/447775 mentions this issue: |
E.g.
Note that the above program is a little constructed; I, personally, am not concerned about break/continue. But I notice that the upcoming new
return
keyword (#53015) uses the same approach. And an app I'm maintaining (Hugo) does have areturn
template func.Go 1.18:
Go 1.19.3:
The text was updated successfully, but these errors were encountered: