Skip to content
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: Parse does not report error line correctly #27319

Closed
jocgir opened this issue Aug 28, 2018 · 1 comment
Closed

text/template: Parse does not report error line correctly #27319

jocgir opened this issue Aug 28, 2018 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jocgir
Copy link

jocgir commented Aug 28, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.11

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jgiroux/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jgiroux/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/b8/dm3gflg51t124m16nvqdxzm9d1phdx/T/go-build077675676=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

If a template contains multiline strings (enclosed in backtick) and there is an error when calling Parse, the error line reported is not correct. However, if an error occurs during Execute, the error reports both line and column and they are correct.

1 	{{ $var := `Multi
2 	
3 	
4 	
5 	Line` -}}
6 	Hello {{ nonExistingFunction $var }}

Error is:
template: test:11: function "nonExistingFunction" not defined
While it should be:
template: test:6: function "nonExistingFunction" not defined

See complete examples on Go Playground

What did you expect to see?

The right error line number 😃, i.e. the same behaviour as in Execute.

What did you see instead?

Error line reported are increased by the number of line composing multiline string previously defined.

@mvdan mvdan added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 28, 2018
@mvdan mvdan added this to the Go1.12 milestone Aug 28, 2018
@mvdan mvdan self-assigned this Aug 28, 2018
@mvdan mvdan changed the title text/template Parse does not report error line correctly text/template: Parse does not report error line correctly Aug 28, 2018
@gopherbot
Copy link

Change https://golang.org/cl/131996 mentions this issue: text/template: fix newline counting in raw strings

@golang golang locked and limited conversation to collaborators Aug 29, 2019
@rsc rsc unassigned mvdan Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants