text/template: incorrect error line number reporting after multiline comments #69526
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version go1.23.0 darwin/amd64
Output of
go env
in your module/workspace:What did you do?
I encountered a problem with incorrect error line number reporting when using the
text/template
package. Specifically, if a template has a multiline comment (e.g.,{{/* ... */}}
), and an error occurs (such as an undefined function) on a line immediately after the comment, the reported error line is incorrect and points to the start of the comment block or earlier.Example code https://go.dev/play/p/YVbgdA-Sj1Z:
What did you see happen?
The error reported the wrong line number):
Template parse error: template: test:2: function "undefinedFunction" not defined
What did you expect to see?
I expected the error to report the correct line where the undefined function is used:
Template parse error: template: test:5: function "undefinedFunction" not defined
The text was updated successfully, but these errors were encountered: