]> Cypherpunks repositories - gostls13.git/commitdiff
gc: minor import grammar bug fixes
authorRuss Cox <rsc@golang.org>
Thu, 3 Dec 2009 08:10:32 +0000 (00:10 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 3 Dec 2009 08:10:32 +0000 (00:10 -0800)
Fixes #364.

R=ken2
https://golang.org/cl/164092

src/cmd/gc/go.y
test/fixedbugs/bug222.dir/chanbug.go [new file with mode: 0644]
test/fixedbugs/bug222.dir/chanbug2.go [new file with mode: 0644]
test/fixedbugs/bug222.go [new file with mode: 0644]

index 8413df64fc3ef4c877f3eb04cf3e09685f9559b5..493dbeecc024cf0c4998cf25ed04e5925edd72cb 100644 (file)
@@ -85,7 +85,9 @@
 %type  <list>  hidden_interfacedcl_list ohidden_interfacedcl_list
 %type  <list>  hidden_structdcl_list ohidden_structdcl_list
 
-%type  <type>  hidden_type hidden_type1 hidden_type2 hidden_pkgtype
+%type  <type>  hidden_type hidden_type_misc hidden_pkgtype
+%type  <type>  hidden_type_func hidden_type_non_func
+%type  <type>  hidden_type_chan hidden_type_non_chan
 
 %left          LOROR
 %left          LANDAND
@@ -1613,10 +1615,19 @@ hidden_pkgtype:
        }
 
 hidden_type:
-       hidden_type1
-|      hidden_type2
+       hidden_type_misc
+|      hidden_type_chan
+|      hidden_type_func
 
-hidden_type1:
+hidden_type_non_chan:
+       hidden_type_misc
+|      hidden_type_func
+
+hidden_type_non_func:
+       hidden_type_misc
+|      hidden_type_chan
+
+hidden_type_misc:
        hidden_importsym
        {
                $$ = pkgtype($1);
@@ -1662,25 +1673,33 @@ hidden_type1:
                $$->type = $3;
                $$->chan = Crecv;
        }
-|      LCHAN LCOMM hidden_type1
+|      LCHAN LCOMM hidden_type_non_chan
        {
                $$ = typ(TCHAN);
                $$->type = $3;
                $$->chan = Csend;
        }
+|      LCHAN LCOMM '(' hidden_type_chan ')'
+       {
+               $$ = typ(TCHAN);
+               $$->type = $4;
+               $$->chan = Csend;
+       }
 |      LDDD
        {
                $$ = typ(TDDD);
        }
 
-hidden_type2:
+hidden_type_chan:
        LCHAN hidden_type
        {
                $$ = typ(TCHAN);
                $$->type = $2;
                $$->chan = Cboth;
        }
-|      LFUNC '(' ohidden_funarg_list ')' ohidden_funres
+
+hidden_type_func:
+       LFUNC '(' ohidden_funarg_list ')' ohidden_funres
        {
                $$ = functype(nil, $3, $5);
        }
@@ -1732,7 +1751,7 @@ hidden_funres:
        {
                $$ = $2;
        }
-|      hidden_type1
+|      hidden_type_non_func
        {
                $$ = list1(nod(ODCLFIELD, N, typenod($1)));
        }
diff --git a/test/fixedbugs/bug222.dir/chanbug.go b/test/fixedbugs/bug222.dir/chanbug.go
new file mode 100644 (file)
index 0000000..9194927
--- /dev/null
@@ -0,0 +1,5 @@
+package chanbug
+var C chan<- (chan int)
+var D chan<- func()
+var E func() chan int
+var F func() (func())
diff --git a/test/fixedbugs/bug222.dir/chanbug2.go b/test/fixedbugs/bug222.dir/chanbug2.go
new file mode 100644 (file)
index 0000000..73e1667
--- /dev/null
@@ -0,0 +1,2 @@
+package Bar
+import _ "chanbug"
diff --git a/test/fixedbugs/bug222.go b/test/fixedbugs/bug222.go
new file mode 100644 (file)
index 0000000..5c23a53
--- /dev/null
@@ -0,0 +1,7 @@
+// $G $D/$F.dir/chanbug.go && $G -I. $D/$F.dir/chanbug2.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.
+
+ignored