aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-01-25 22:10:35 -0800
committerRobert Griesemer <gri@golang.org>2010-01-25 22:10:35 -0800
commitf4dfbd1cf03abaac35f912a91e5f60885c099bb1 (patch)
tree41a397d3a5d779ce74bd1f9a8bfcce4c72cd9f1c
parent3884f7321f7f79e6bb32029dff83882d42704cba (diff)
downloadgo-f4dfbd1cf03abaac35f912a91e5f60885c099bb1.tar.gz
go-f4dfbd1cf03abaac35f912a91e5f60885c099bb1.zip
channel types parsed not according to spec by 6g
R=r, rsc CC=golang-dev https://golang.org/cl/193101
-rw-r--r--test/bugs/bug249.go39
-rw-r--r--test/golden.out7
2 files changed, 46 insertions, 0 deletions
diff --git a/test/bugs/bug249.go b/test/bugs/bug249.go
new file mode 100644
index 0000000000..642170d072
--- /dev/null
+++ b/test/bugs/bug249.go
@@ -0,0 +1,39 @@
+// errchk $G $D/$F.go
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+var c1 chan<- chan int
+var c2 chan<- (chan int) // same type as c1 according to gccgo, gofmt
+var c3 chan (<-chan int) // same type as c1 according to 6g
+
+func main() {
+ c1 = c2 // this should be ok, bug 6g doesn't accept it
+ c1 = c3 // ERROR "chan"
+}
+
+/*
+Channel types are parsed differently by 6g then by gccgo and gofmt.
+The channel type specification ( http://golang.org/doc/go_spec.html#Channel_types )
+says that a channel type is either
+
+ chan ElementType
+ chan <- ElementType
+ <-chan ElementType
+
+which indicates that the <- binds to the chan token (not to the ElementType).
+So:
+
+chan <- chan int
+
+should be parsed as
+
+chan<- (chan int)
+
+Both gccgo and gofmt adhere to this, while 6g parses this as
+
+chan (<-chan int)
+*/
diff --git a/test/golden.out b/test/golden.out
index d87842e4ff..af57491180 100644
--- a/test/golden.out
+++ b/test/golden.out
@@ -154,3 +154,10 @@ BUG: tuple evaluation order
bugs/bug246.go:17: cannot convert 0 to type unsafe.Pointer
bugs/bug246.go:17: cannot convert 0 (type uintptr) to type *int in conversion
BUG: bug246
+
+=========== bugs/bug249.go
+BUG: errchk: bugs/bug249.go:15: missing expected error: 'chan'
+errchk: bugs/bug249.go: unmatched error messages:
+==================================================
+bugs/bug249.go:14: cannot use c2 (type chan<- (chan int)) as type chan <-chan int in assignment
+==================================================