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
Assignees

Comments

@julianbrost
Copy link

@julianbrost julianbrost commented May 2, 2019

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
Member

@katiehockman katiehockman commented May 3, 2019

@robpike robpike self-assigned this May 3, 2019
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 10, 2019

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

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 5, 2020

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.