1 // errorcheck 2 3 // Copyright 2015 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Check that we correctly construct (and report errors) 8 // for unary expressions of the form <-x where we only 9 // know after parsing x whether <-x is a receive operation 10 // or a channel type. 11 12 package n 13 14 func f() { 15 // test case from issue 13273 16 <-chan int((chan int)(nil)) 17 18 <-chan int(nil) 19 <-chan chan int(nil) 20 <-chan chan chan int(nil) 21 <-chan chan chan chan int(nil) 22 <-chan chan chan chan chan int(nil) 23 24 <-chan<-chan int(nil) 25 <-chan<-chan<-chan int(nil) 26 <-chan<-chan<-chan<-chan int(nil) 27 <-chan<-chan<-chan<-chan<-chan int(nil) 28 29 <-chan (<-chan int)(nil) 30 <-chan (<-chan (<-chan int))(nil) 31 <-chan (<-chan (<-chan (<-chan int)))(nil) 32 <-chan (<-chan (<-chan (<-chan (<-chan int))))(nil) 33 34 <-(<-chan int)(nil) 35 <-(<-chan chan int)(nil) 36 <-(<-chan chan chan int)(nil) 37 <-(<-chan chan chan chan int)(nil) 38 <-(<-chan chan chan chan chan int)(nil) 39 40 <-(<-chan<-chan int)(nil) 41 <-(<-chan<-chan<-chan int)(nil) 42 <-(<-chan<-chan<-chan<-chan int)(nil) 43 <-(<-chan<-chan<-chan<-chan<-chan int)(nil) 44 45 <-(<-chan (<-chan int))(nil) 46 <-(<-chan (<-chan (<-chan int)))(nil) 47 <-(<-chan (<-chan (<-chan (<-chan int))))(nil) 48 <-(<-chan (<-chan (<-chan (<-chan (<-chan int)))))(nil) 49 50 type _ <-<-chan int // ERROR "unexpected <-, expecting chan" 51 <-<-chan int // ERROR "unexpected <-, expecting chan|expecting {" (new parser: same error as for type decl) 52 53 type _ <-chan<-int // ERROR "unexpected int, expecting chan|expecting chan" 54 <-chan<-int // ERROR "unexpected int, expecting chan|expecting {" (new parser: same error as for type decl) 55 } 56