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

     1  // errorcheck
     2  
     3  // Copyright 2012 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  // Used to crash compiler in interface type equality check.
     8  // (This test used to have problems - see #15596.)
     9  
    10  package p
    11  
    12  // exported interfaces
    13  
    14  type I1 interface {
    15  	F() interface{ I1 }
    16  }
    17  
    18  type I2 interface {
    19  	F2() interface{ I2 }
    20  }
    21  
    22  var V1 I1
    23  var V2 I2
    24  
    25  func F() bool {
    26  	return V1 == V2 // ERROR "invalid operation: V1 == V2 \(mismatched types I1 and I2\)"
    27  }
    28  
    29  // non-exported interfaces
    30  
    31  type i1 interface {
    32  	F() interface{ i1 }
    33  }
    34  
    35  type i2 interface {
    36  	F2() interface{ i2 }
    37  }
    38  
    39  var v1 i1
    40  var v2 i2
    41  
    42  func f() bool {
    43  	return v1 == v2 // ERROR "invalid operation: v1 == v2 \(mismatched types i1 and i2\)"
    44  }