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: break/continue require no whitespace around them #51670

Closed
JRaspass opened this issue Mar 14, 2022 · 8 comments
Closed

text/template: break/continue require no whitespace around them #51670

JRaspass opened this issue Mar 14, 2022 · 8 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@JRaspass
Copy link

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

$ go version
go version go1.18rc1 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18rc1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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=/tmp/go-build149032034=/tmp/go-build -gno-record-gcc-switches"

What did you do?

break/continue in templates require no whitespace around them unlike other keywords.
https://go.dev/play/p/pbmCi6ystSG?v=gotip

What did you expect to see?

{{ range . }}{{ continue }}{{ end }} compiles fine.

What did you see instead?

panic: template: :1: unexpected " " in in {{continue}}
@heschi heschi added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 14, 2022
@heschi heschi added this to the Backlog milestone Mar 14, 2022
@heschi
Copy link
Contributor

heschi commented Mar 14, 2022

cc @robpike @rsc

@robpike robpike self-assigned this Mar 14, 2022
@gopherbot
Copy link

Change https://go.dev/cl/392615 mentions this issue: text/template/parse: allow space after continue or break

@robpike robpike added the CherryPickCandidate Used during the release process for point releases label Mar 15, 2022
@martinrode
Copy link

martinrode commented May 11, 2022

Shouldn’t this ticket be open until its merged?

Quick test shows it’s not working yet:

https://go.dev/play/p/b9PeeCUue1N

@seankhliao
Copy link
Member

It is merged into tip

@martinrode
Copy link

How about a backport to the next point release?

@ianlancetaylor
Copy link
Contributor

@gopherbot Please open a backport to 1.18.

These new text/template features are new in the 1.18 release, but they have a oddity in that don't permit whitespace. It's probably worth fixing that in 1.18 so that they people don't have to slightly contort their new code until 1.19 comes out.

@gopherbot
Copy link

Backport issue(s) opened: #52878 (for 1.18), #52879 (for 1.19).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link

Change https://go.dev/cl/406074 mentions this issue: [release-branch.go1.18] text/template/parse: allow space after continue or break

gopherbot pushed a commit that referenced this issue May 26, 2022
…ue or break

Trivial fix: We must skip space after either of these keywords
before we expect a closing delimiter.

Also delete the stutter-generating extra 'in' in the error message.
(See what I did there?)

For #51670
Fixes #52878

Change-Id: If5415632c36eaac6699bdc0aa6ce18be956c9b53
Reviewed-on: https://go-review.googlesource.com/c/go/+/392615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 41a82aa)
Reviewed-on: https://go-review.googlesource.com/c/go/+/406074
Reviewed-by: Alex Rakoczy <alex@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
@dmitshur dmitshur modified the milestones: Backlog, Go1.19 May 30, 2022
@dmitshur dmitshur removed the CherryPickCandidate Used during the release process for point releases label May 30, 2022
@rsc rsc unassigned robpike Jun 22, 2022
giautm added a commit to giautm/ent that referenced this issue Sep 26, 2022
Related: golang/go#51670
Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
giautm added a commit to giautm/ent that referenced this issue Sep 26, 2022
Related: golang/go#51670
Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
a8m pushed a commit to ent/ent that referenced this issue Sep 26, 2022
Related: golang/go#51670
Signed-off-by: Giau. Tran Minh <hello@giautm.dev>

Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
setnicka added a commit to setnicka/shrecker that referenced this issue Jan 5, 2023
@golang golang locked and limited conversation to collaborators Jun 22, 2023
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

8 participants