Commit ebc10db3 authored by Russ Cox's avatar Russ Cox

allow parens to disambiguate types.

examples:

	chan <- (chan int)
	chan (<- chan int)
	(map[string]func())("a": main)

R=ken
OCL=25151
CL=25151
parent 6950491b
...@@ -1004,6 +1004,10 @@ convtype: ...@@ -1004,6 +1004,10 @@ convtype:
$$->type = $5; $$->type = $5;
} }
| structtype | structtype
| '(' type ')'
{
$$ = $2;
}
/* /*
* to avoid parsing conflicts, type is split into * to avoid parsing conflicts, type is split into
...@@ -1031,6 +1035,10 @@ Btype: ...@@ -1031,6 +1035,10 @@ Btype:
| Bchantype | Bchantype
| Bfntype | Bfntype
| Bothertype | Bothertype
| '(' type ')'
{
$$ = $2;
}
non_name_type: non_name_type:
chantype chantype
...@@ -1052,6 +1060,10 @@ Bnon_chan_type: ...@@ -1052,6 +1060,10 @@ Bnon_chan_type:
nametype nametype
| Bfntype | Bfntype
| Bothertype | Bothertype
| '(' Btype ')'
{
$$ = $2;
}
Anon_fn_type: Anon_fn_type:
Achantype Achantype
...@@ -1062,7 +1074,6 @@ Bnon_fn_type: ...@@ -1062,7 +1074,6 @@ Bnon_fn_type:
| Bchantype | Bchantype
| Bothertype | Bothertype
nametype: nametype:
LATYPE LATYPE
{ {
......
// $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
func f(interface{})
func g() {}
func main() {
f(map[string]string("a":"b","c":"d"));
f((map[string]string)("a":"b","c":"d"));
f((map[string]func())("a":g,"c":g));
f(make(chan(<-chan int)));
f(make(chan<-(chan int)));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment