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: unintuitive behavior of parenthesized arguments in text/template and html/template #31810

Closed
julianbrost opened this issue May 2, 2019 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@julianbrost
Copy link

What did you do?

Execute a template like {{ (1) 2 }} with text/template and html/template. Full example on Go Playground: https://play.golang.org/p/nDdB_6tzx8G

What did you expect to see?

I'd expect {{ 1 2 }} and {{ (1) 2 }} to behave the same.The last item at https://golang.org/pkg/text/template/#hdr-Arguments reads like parenthesizing a single argument should have no effect.

What did you see instead?

{{ 1 2 }} yields an error (as I'd expect) but {{ (1) 2 }} outputs 1 without an error.

System details

go version go1.12.4 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/julian/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/julian/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.12.4 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.12.4
uname -sr: Linux 5.0.9-arch1-1-ARCH
LSB Version:	1.4
Distributor ID:	Arch
Description:	Arch Linux
Release:	rolling
Codename:	n/a
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.29.
gdb --version: GNU gdb (GDB) 8.2.1
@julianbrost julianbrost changed the title Unintuitive behavor of parenthesized arguments in text/template and html/template Unintuitive behavior of parenthesized arguments in text/template and html/template May 2, 2019
@katiehockman katiehockman changed the title Unintuitive behavior of parenthesized arguments in text/template and html/template text/template: unintuitive behavior of parenthesized arguments in text/template and html/template May 3, 2019
@katiehockman
Copy link
Contributor

/cc @mvdan @robpike

@katiehockman katiehockman added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 3, 2019
@robpike robpike self-assigned this May 3, 2019
@gopherbot
Copy link

Change https://golang.org/cl/206124 mentions this issue: text/template: add error check for parenthesized first argument in pipeline

@gopherbot
Copy link

Change https://golang.org/cl/217978 mentions this issue: doc/go1.14: mention better error checking in text/template

gopherbot pushed a commit that referenced this issue Feb 5, 2020
This caused 35 test failures in Google internal code,
so it's worth mentioning in the release notes.

Updates #31810
Updates #36878
Fixes #37066

Change-Id: I2faa6bce4c7d735107eceaef7d95223844846454
Reviewed-on: https://go-review.googlesource.com/c/go/+/217978
Reviewed-by: Rob Pike <r@golang.org>
@golang golang locked and limited conversation to collaborators Feb 4, 2021
@rsc rsc unassigned robpike Jun 23, 2022
@dmitshur dmitshur added this to the Go1.14 milestone Dec 15, 2022
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Dec 15, 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

5 participants