modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue13821b.go (about)

     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  // Issue 13821.  Additional regress tests.
     8  
     9  package p
    10  
    11  type B bool
    12  type B2 bool
    13  
    14  var b B
    15  var b2 B2
    16  var x1 = b && 1 < 2 // x1 has type B, not ideal bool
    17  var x2 = 1 < 2 && b // x2 has type B, not ideal bool
    18  var x3 = b && b2    // ERROR "mismatched types B and B2"
    19  var x4 = x1 && b2   // ERROR "mismatched types B and B2"
    20  var x5 = x2 && b2   // ERROR "mismatched types B and B2"
    21  var x6 = b2 && x1   // ERROR "mismatched types B2 and B"
    22  var x7 = b2 && x2   // ERROR "mismatched types B2 and B"
    23  
    24  var x8 = b && !B2(true) // ERROR "mismatched types B and B2"