@@ -124,6 +124,10 @@ fn (mut p Parser) parse_array_type(expecting token.Kind, is_option bool) ast.Typ
124124 // error is handled by parse_type
125125 return 0
126126 }
127+ if elem_type == ast.chan_type {
128+ p.chan_type_error ()
129+ return 0
130+ }
127131 // has been explicitly resolved, but size is 0
128132 if fixed_size < = 0 && ! size_unresolved {
129133 p.error_with_pos ('fixed size cannot be zero or negative' , size_expr.pos ())
@@ -142,6 +146,10 @@ fn (mut p Parser) parse_array_type(expecting token.Kind, is_option bool) ast.Typ
142146 // error is set in parse_type
143147 return 0
144148 }
149+ if elem_type == ast.chan_type {
150+ p.chan_type_error ()
151+ return 0
152+ }
145153 if elem_type.idx () == ast.thread_type_idx {
146154 p.register_auto_import ('sync.threads' )
147155 }
@@ -201,6 +209,10 @@ fn (mut p Parser) parse_map_type() ast.Type {
201209 // error is reported in parse_type
202210 return 0
203211 }
212+ if value_type == ast.chan_type {
213+ p.chan_type_error ()
214+ return 0
215+ }
204216 if value_type.idx () == ast.void_type_idx {
205217 p.error_with_pos ('map value type is missing: use `map[KeyType]ValueType`' , p.tok.pos ())
206218 return 0
@@ -293,6 +305,10 @@ fn (mut p Parser) parse_multi_return_type() ast.Type {
293305 if mr_type.idx () == 0 {
294306 break
295307 }
308+ if mr_type == ast.chan_type {
309+ p.chan_type_error ()
310+ break
311+ }
296312 if mr_type.has_flag (.generic) {
297313 has_generic = true
298314 }
@@ -568,6 +584,11 @@ fn (mut p Parser) parse_type() ast.Type {
568584 // error is set in parse_type
569585 return 0
570586 }
587+ // !p.inside_receiver_param check can be removed once (ch chan) functions are removed
588+ if typ == ast.chan_type && ! p.inside_receiver_param {
589+ p.chan_type_error ()
590+ return 0
591+ }
571592 if typ == ast.void_type {
572593 p.error_with_pos ('use `?` instead of `?void`' , pos)
573594 return 0
0 commit comments