Open mkideal opened 4 days ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Change https://go.dev/cl/614375 mentions this issue: template:fix line number is wrong in error info
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