Skip to content

text/template: unintuitive behavior of parenthesized arguments in text/template and html/template #31810

@julianbrost

Description

@julianbrost

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions