summaryrefslogtreecommitdiff
path: root/test/parentype.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-07-29 18:13:41 -0700
committerRobert Griesemer <gri@golang.org>2010-07-29 18:13:41 -0700
commit07cc6440dc2ec35e2a216e13dd8aed9208649a77 (patch)
tree83f0220f3aa9967ad7fdf58339651debf3d5b5c4 /test/parentype.go
parentbab711b184e7737d25f3efa04d55fec9e809a386 (diff)
downloadgo-git-07cc6440dc2ec35e2a216e13dd8aed9208649a77.tar.gz
go_spec: don't allow parens around the literal type of composite literals
Background: The current spec is imprecise with respect to the parsing ambiguity for composite literals: It says that the ambiguity arises when the TypeName form of the LiteralType is used. The following code: if (B) {} ... is not using the TypeName form (but the parenthesized TypeName form) and thus could be interpreted as: if ((B){}) ... instead of if B {} ... Both compilers and gofmt choose the latter interpretation. One could fix the spec by making the clause regarding the parsing ambiguity more precise ("...using the _possibly parenthesized_ TypeName form of the LiteralType..."). The alternative (chosen here) is to simply disallow parenthesized literal types. Except for a single test case (test/parentype.go) there appears to be no Go code under $GOROOT containing parenthesized literal types. Furthermore, parentheses are never needed around a literal type for correct parsing. R=golang-dev CC=golang-dev https://golang.org/cl/1913041
Diffstat (limited to 'test/parentype.go')
-rw-r--r--test/parentype.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/test/parentype.go b/test/parentype.go
index d5729f820d..efab5a97de 100644
--- a/test/parentype.go
+++ b/test/parentype.go
@@ -11,9 +11,7 @@ func g() {}
func main() {
f(map[string]string{"a":"b","c":"d"});
f([...]int{1,2,3});
- f(([...]int){1,2,3});
- f((map[string]string){"a":"b","c":"d"});
- f((map[string]func()){"a":g,"c":g});
+ f(map[string]func(){"a":g,"c":g});
f(make(chan(<-chan int)));
f(make(chan<-(chan int)));
}