Source file test/chan/element_type_too_large.go

     1  // errorcheck -e
     2  
     3  // Copyright 2026 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  package p
     8  
     9  func f() {
    10  	n := len(make(chan struct{ v [65536]byte })) // ERROR "channel element type too large"
    11  	_ = n
    12  }
    13  
    14  func g() {
    15  	for v := range make(chan struct{ v [65536]byte }) { // ERROR "channel element type too large"
    16  		_ = v
    17  	}
    18  }
    19  
    20  func h(x int) {
    21  	for v := 0; v < len(make(chan struct{ v [65536]byte })); v++ { // ERROR "channel element type too large"
    22  	}
    23  	for v := 0; v < 10; v += len(make(chan struct{ v [65536]byte })) { // ERROR "channel element type too large"
    24  	}
    25  	if v := 0; v < len(make(chan struct{ v [65536]byte })) { // ERROR "channel element type too large"
    26  		_ = v
    27  	}
    28  	switch v := 0; v + len(make(chan struct{ v [65536]byte })) { // ERROR "channel element type too large"
    29  	}
    30  	switch v := 0; x {
    31  	case v + len(make(chan struct{ v [65536]byte })): // ERROR "channel element type too large"
    32  	}
    33  	switch v := 0; y := any(make(chan struct{ v [65536]byte })).(type) { // ERROR "channel element type too large"
    34  	default:
    35  		_, _ = v, y
    36  	}
    37  	select {
    38  	case v := <-make(chan struct{ v [65536]byte }): // ERROR "channel element type too large"
    39  		_ = v
    40  	case v, ok := <-make(chan struct{ v [65536]byte }): // ERROR "channel element type too large"
    41  		_, _ = v, ok
    42  	}
    43  }
    44  
    45  func multiline() {
    46  	var a,
    47  		b = 1, len(make(chan struct{ v [65536]byte })) // ERROR "channel element type too large"
    48  	_, _ = a, b
    49  
    50  	for a,
    51  		b := 0, 0; a+b < len(make(chan struct{ v [65536]byte })); a++ { // ERROR "channel element type too large"
    52  	}
    53  	if a,
    54  		b := 0, 0; a+b < len(make(chan struct{ v [65536]byte })) { // ERROR "channel element type too large"
    55  		_, _ = a, b
    56  	}
    57  	switch a,
    58  		b := 0, 0; a + b + len(make(chan struct{ v [65536]byte })) { // ERROR "channel element type too large"
    59  	}
    60  	switch v := 0;
    61  	y := any(make(chan struct{ v [65536]byte })).(type) { // ERROR "channel element type too large"
    62  	default:
    63  		_, _ = v, y
    64  	}
    65  }
    66  

View as plain text